mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Add internal Format structure for texture formats
Texture formats have plenty of properties we'd like to query on them like their texel size, whether they are compressend or if they are depth stencil. Instead of making switch statements for each of these properties, we store them in a new `Format` structure. Textures compute their format only onces and then pass a const reference to it on GetFormat(). This is in preparation of adding all WebGPU texture formats. BUG=dawn:128 Change-Id: Iad2831cf16f14e1a1bfce2c10b22527fc982d1aa Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8166 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
4729b15365
commit
a92f83b725
@@ -102,7 +102,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
bool RequiresCreatingNewTextureView(const TextureBase* texture,
|
||||
const TextureViewDescriptor* textureViewDescriptor) {
|
||||
if (texture->GetFormat() != textureViewDescriptor->format) {
|
||||
if (texture->GetFormat().format != textureViewDescriptor->format) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace dawn_native { namespace opengl {
|
||||
uint32_t arrayLayers = GetArrayLayers();
|
||||
uint32_t sampleCount = GetSampleCount();
|
||||
|
||||
auto formatInfo = GetGLFormatInfo(GetFormat());
|
||||
auto formatInfo = GetGLFormatInfo(GetFormat().format);
|
||||
|
||||
gl.BindTexture(mTarget, mHandle);
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
if (GetDevice()->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
|
||||
static constexpr uint32_t MAX_TEXEL_SIZE = 16;
|
||||
ASSERT(TextureFormatTexelBlockSizeInBytes(GetFormat()) <= MAX_TEXEL_SIZE);
|
||||
ASSERT(GetFormat().blockByteSize <= MAX_TEXEL_SIZE);
|
||||
GLubyte clearColor[MAX_TEXEL_SIZE];
|
||||
std::fill(clearColor, clearColor + MAX_TEXEL_SIZE, 255);
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
TextureFormatInfo Texture::GetGLFormat() const {
|
||||
return GetGLFormatInfo(GetFormat());
|
||||
return GetGLFormatInfo(GetFormat().format);
|
||||
}
|
||||
|
||||
// TextureView
|
||||
|
||||
Reference in New Issue
Block a user