Fix redundant writes to compressed texture
We already dispatch one workgroup per block, so there's no need to then
loop over all the blocks in the compute shader. Just write one block per
invocation.
Components: Vulkan
Affects:
dEQP-VK.image.sample_texture.128_bit_compressed_format*
dEQP-VK.image.sample_texture.64_bit_compressed_format*
VK-GL-CTS Issue: 3582
Change-Id: If1cf7d4a79e00dcfe735aa9c4d97220242283a12
diff --git a/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp b/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp
index 9e5f571..3879b6a 100644
--- a/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp
+++ b/external/vulkancts/modules/vulkan/image/vktImageSampleCompressedTextureTests.cpp
@@ -279,6 +279,12 @@
.addType(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
.build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 3u));
const VkFormat renderedImageFormat = VK_FORMAT_R8G8B8A8_UNORM;
+ tcu::CompressedTexFormat compressedFormat (mapVkCompressedFormat(m_imageFormat));
+ IVec3 blockSize = tcu::getBlockPixelSize(compressedFormat);
+
+ DE_ASSERT(blockSize.z() == 1);
+
+ IVec3 storageImageViewSize = imageSize / blockSize;
// Create a storage image. The first pipeline fills it with pure blue and the second pipeline
// uses it as a sampling source.
@@ -438,7 +444,7 @@
vk.cmdBindPipeline(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipeline);
vk.cmdPushConstants(*cmdBuffer, *computePipelineLayout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(deInt32), &pass);
- vk.cmdDispatch(*cmdBuffer, WIDTH, HEIGHT, 1u);
+ vk.cmdDispatch(*cmdBuffer, storageImageViewSize.x(), storageImageViewSize.y(), 1u);
const auto barrier2 = makeImageMemoryBarrier(VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL,
VK_IMAGE_LAYOUT_GENERAL, storageImage.get(), imageSubresourceRange);
@@ -558,11 +564,6 @@
std::string bc3_red = " uvec4(4294967295u, 4294967295u, 4160813056u, 0u);\n";
std::string bc3_blue = "uvec4(4294967295u, 4294967295u, 2031647, 0u);\n";
- tcu::CompressedTexFormat compressedFormat (mapVkCompressedFormat(m_imageFormat));
- IVec3 blockSize = tcu::getBlockPixelSize(compressedFormat);
-
- DE_ASSERT(blockSize.z() == 1);
-
std::ostringstream computeSrc;
computeSrc
<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
@@ -592,11 +593,7 @@
computeSrc << " }\n";
}
computeSrc
- << " for (int x = 0; x < " << WIDTH / blockSize << "; x++) {\n"
- << " for (int y = 0; y < " << HEIGHT / blockSize << "; y++) {\n"
- << " imageStore(img, ivec2(x, y), color);\n"
- << " }\n"
- << " }\n"
+ << " imageStore(img, ivec2(gl_GlobalInvocationID.xy), color);\n"
<< "}\n";
std::ostringstream vertexSrc;