mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Format: Move the TexelBlockInfo inside an AspectInfo.
In follow up CLs additional will be added to the AspectInfo, like the supported component types. Also simplify the logic for GetTexelInfo since all aspects are the first aspects, except stencil which is always stencil8. Bug: dawn:517 Change-Id: Iebbcb8a7f8fa2c4b7b06f65d6e4e8917c0a85366 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30100 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
84b70a6e4d
commit
6298d2b70c
@@ -294,8 +294,8 @@ namespace dawn_native { namespace opengl {
|
||||
ASSERT(range.aspects == Aspect::Color);
|
||||
|
||||
static constexpr uint32_t MAX_TEXEL_SIZE = 16;
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetTexelBlockInfo(Aspect::Color);
|
||||
ASSERT(blockInfo.blockByteSize <= MAX_TEXEL_SIZE);
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(Aspect::Color).block;
|
||||
ASSERT(blockInfo.byteSize <= MAX_TEXEL_SIZE);
|
||||
|
||||
std::array<GLbyte, MAX_TEXEL_SIZE> clearColorData;
|
||||
clearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0 : 255;
|
||||
@@ -324,20 +324,19 @@ namespace dawn_native { namespace opengl {
|
||||
ASSERT(range.aspects == Aspect::Color);
|
||||
|
||||
// create temp buffer with clear color to copy to the texture image
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetTexelBlockInfo(Aspect::Color);
|
||||
ASSERT(kTextureBytesPerRowAlignment % blockInfo.blockByteSize == 0);
|
||||
uint32_t bytesPerRow =
|
||||
Align((GetWidth() / blockInfo.blockWidth) * blockInfo.blockByteSize,
|
||||
kTextureBytesPerRowAlignment);
|
||||
const TexelBlockInfo& blockInfo = GetFormat().GetAspectInfo(Aspect::Color).block;
|
||||
ASSERT(kTextureBytesPerRowAlignment % blockInfo.byteSize == 0);
|
||||
uint32_t bytesPerRow = Align((GetWidth() / blockInfo.width) * blockInfo.byteSize,
|
||||
kTextureBytesPerRowAlignment);
|
||||
|
||||
// Make sure that we are not rounding
|
||||
ASSERT(bytesPerRow % blockInfo.blockByteSize == 0);
|
||||
ASSERT(GetHeight() % blockInfo.blockHeight == 0);
|
||||
ASSERT(bytesPerRow % blockInfo.byteSize == 0);
|
||||
ASSERT(GetHeight() % blockInfo.height == 0);
|
||||
|
||||
dawn_native::BufferDescriptor descriptor = {};
|
||||
descriptor.mappedAtCreation = true;
|
||||
descriptor.usage = wgpu::BufferUsage::CopySrc;
|
||||
descriptor.size = bytesPerRow * (GetHeight() / blockInfo.blockHeight);
|
||||
descriptor.size = bytesPerRow * (GetHeight() / blockInfo.height);
|
||||
if (descriptor.size > std::numeric_limits<uint32_t>::max()) {
|
||||
return DAWN_OUT_OF_MEMORY_ERROR("Unable to allocate buffer.");
|
||||
}
|
||||
@@ -353,7 +352,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
// Bind buffer and texture, and make the buffer to texture copy
|
||||
gl.PixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||
(bytesPerRow / blockInfo.blockByteSize) * blockInfo.blockWidth);
|
||||
(bytesPerRow / blockInfo.byteSize) * blockInfo.width);
|
||||
gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
|
||||
for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
|
||||
++level) {
|
||||
|
||||
Reference in New Issue
Block a user