mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
Refactor Internal Command Buffer Copy APIs
Modify internal command buffer types to reflect the front end APIs for copyTextureToBuffer and copyBufferToTexture. Bug: dawn:17 Change-Id: I088a167ee7145d741e70ed28c1df7a12d24b72fc Reviewed-on: https://dawn-review.googlesource.com/c/2740 Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
5acd60c929
commit
179db44c25
@@ -321,6 +321,7 @@ namespace dawn_native { namespace opengl {
|
||||
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
|
||||
auto& src = copy->source;
|
||||
auto& dst = copy->destination;
|
||||
auto& copySize = copy->copySize;
|
||||
Buffer* buffer = ToBackend(src.buffer.Get());
|
||||
Texture* texture = ToBackend(dst.texture.Get());
|
||||
GLenum target = texture->GetGLTarget();
|
||||
@@ -331,18 +332,18 @@ namespace dawn_native { namespace opengl {
|
||||
glBindTexture(target, texture->GetHandle());
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||
copy->rowPitch / TextureFormatPixelSize(texture->GetFormat()));
|
||||
src.rowPitch / TextureFormatPixelSize(texture->GetFormat()));
|
||||
switch (texture->GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
if (texture->GetArrayLayers() > 1) {
|
||||
glTexSubImage3D(
|
||||
target, dst.level, dst.x, dst.y, dst.slice, dst.width,
|
||||
dst.height, 1, format.format, format.type,
|
||||
target, dst.level, dst.origin.x, dst.origin.y, dst.slice,
|
||||
copySize.width, copySize.height, 1, format.format, format.type,
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(src.offset)));
|
||||
} else {
|
||||
glTexSubImage2D(
|
||||
target, dst.level, dst.x, dst.y, dst.width, dst.height,
|
||||
format.format, format.type,
|
||||
target, dst.level, dst.origin.x, dst.origin.y, copySize.width,
|
||||
copySize.height, format.format, format.type,
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(src.offset)));
|
||||
}
|
||||
break;
|
||||
@@ -359,6 +360,7 @@ namespace dawn_native { namespace opengl {
|
||||
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
|
||||
auto& src = copy->source;
|
||||
auto& dst = copy->destination;
|
||||
auto& copySize = copy->copySize;
|
||||
Texture* texture = ToBackend(src.texture.Get());
|
||||
Buffer* buffer = ToBackend(dst.buffer.Get());
|
||||
auto format = texture->GetGLFormat();
|
||||
@@ -390,11 +392,11 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer->GetHandle());
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH,
|
||||
copy->rowPitch / TextureFormatPixelSize(texture->GetFormat()));
|
||||
ASSERT(src.depth == 1 && src.z == 0);
|
||||
dst.rowPitch / TextureFormatPixelSize(texture->GetFormat()));
|
||||
ASSERT(copySize.depth == 1 && src.origin.z == 0);
|
||||
void* offset = reinterpret_cast<void*>(static_cast<uintptr_t>(dst.offset));
|
||||
glReadPixels(src.x, src.y, src.width, src.height, format.format, format.type,
|
||||
offset);
|
||||
glReadPixels(src.origin.x, src.origin.y, copySize.width, copySize.height,
|
||||
format.format, format.type, offset);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
|
||||
Reference in New Issue
Block a user