mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Implement backend texture->buffer and buffer->texture copies with row pitch
This commit is contained in:
@@ -181,9 +181,11 @@ namespace opengl {
|
||||
glBindTexture(target, texture->GetHandle());
|
||||
|
||||
ASSERT(texture->GetDimension() == nxt::TextureDimension::e2D);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, copy->rowPitch / static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat())));
|
||||
glTexSubImage2D(target, dst.level, dst.x, dst.y, dst.width, dst.height,
|
||||
format.format, format.type,
|
||||
reinterpret_cast<void*>(static_cast<uintptr_t>(src.offset)));
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
}
|
||||
break;
|
||||
@@ -210,9 +212,11 @@ namespace opengl {
|
||||
texture->GetHandle(), src.level);
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer->GetHandle());
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, copy->rowPitch / static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat())));
|
||||
ASSERT(src.depth == 1 && src.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);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
glDeleteFramebuffers(1, &readFBO);
|
||||
|
||||
Reference in New Issue
Block a user