Add nonzero_clear_resources_on_creation_for_testing toggle to opengl
Forces texture to clear to nonzero on creation to test the logic of lazy clearing. Bug: dawn:145 Change-Id: Ib1f6e8f961927008e3c09960ad0219f975d86cc6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7240 Commit-Queue: Natasha Lee <natlee@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
2bc3169f0d
commit
2a7b631482
|
@ -33,6 +33,9 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
Device::Device(AdapterBase* adapter, const DeviceDescriptor* descriptor)
|
Device::Device(AdapterBase* adapter, const DeviceDescriptor* descriptor)
|
||||||
: DeviceBase(adapter, descriptor) {
|
: DeviceBase(adapter, descriptor) {
|
||||||
|
if (descriptor != nullptr) {
|
||||||
|
ApplyToggleOverrides(descriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::~Device() {
|
Device::~Device() {
|
||||||
|
|
|
@ -166,6 +166,18 @@ namespace dawn_native { namespace opengl {
|
||||||
// The texture is not complete if it uses mipmapping and not all levels up to
|
// The texture is not complete if it uses mipmapping and not all levels up to
|
||||||
// MAX_LEVEL have been defined.
|
// MAX_LEVEL have been defined.
|
||||||
glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, levels - 1);
|
glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, levels - 1);
|
||||||
|
|
||||||
|
if (GetDevice()->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) {
|
||||||
|
static constexpr uint32_t MAX_TEXEL_SIZE = 16;
|
||||||
|
ASSERT(TextureFormatPixelSize(GetFormat()) <= MAX_TEXEL_SIZE);
|
||||||
|
GLubyte clearColor[MAX_TEXEL_SIZE];
|
||||||
|
std::fill(clearColor, clearColor + MAX_TEXEL_SIZE, 255);
|
||||||
|
|
||||||
|
// TODO(natlee@microsoft.com): clear all subresources
|
||||||
|
for (uint32_t i = 0; i < GL_TEXTURE_MAX_LEVEL; i++) {
|
||||||
|
glClearTexImage(mHandle, i, formatInfo.format, formatInfo.type, clearColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture::Texture(Device* device,
|
Texture::Texture(Device* device,
|
||||||
|
|
|
@ -95,5 +95,7 @@ TEST_P(NonzeroTextureCreationTests, ArrayLayerClears) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests,
|
DAWN_INSTANTIATE_TEST(NonzeroTextureCreationTests,
|
||||||
|
ForceWorkaround(OpenGLBackend,
|
||||||
|
"nonzero_clear_resources_on_creation_for_testing"),
|
||||||
ForceWorkaround(VulkanBackend,
|
ForceWorkaround(VulkanBackend,
|
||||||
"nonzero_clear_resources_on_creation_for_testing"));
|
"nonzero_clear_resources_on_creation_for_testing"));
|
||||||
|
|
Loading…
Reference in New Issue