const Move<VkCommandPool> cmdPool = createCommandPool(vk, device, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, queueFamilyIndex);
const Move<VkCommandBuffer> cmdBuffer = allocateCommandBuffer(vk, device, *cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
- const Unique<VkDescriptorPool> descriptorPool (DescriptorPoolBuilder().addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE)
- .addType(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
- .addType(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
- .build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 3u));
+ const Unique<VkDescriptorPool> descriptorPool (DescriptorPoolBuilder()
+ .addType(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 6)
+ .addType(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 12)
+ .build(vk, device, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 21u));
+
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
+ // Create a storage image. The first pipeline fills it and the second pipeline
// uses it as a sampling source.
- const VkImageCreateInfo imageCreateInfo = makeImageCreateInfo(imageSize, m_imageFormat, true);
+ const VkImageCreateInfo imageCreateInfo = makeImageCreateInfo(imageSize, m_imageFormat, true, m_cubemap);
const VkImageSubresourceRange imageSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1, 0, 1);
const ImageWithMemory storageImage (vk, device, m_context.getDefaultAllocator(), imageCreateInfo, MemoryRequirement::Any);
- Move<VkImageView> storageImageImageView = makeImageView(vk, device, *storageImage, VK_IMAGE_VIEW_TYPE_2D, m_imageViewFormat, imageSubresourceRange);
- Move<VkShaderModule> computeShader = createShaderModule (vk, device, m_context.getBinaryCollection().get("comp"), 0u);
+ // Create image views and descriptor sets for the first pipeline
+ Move<VkDescriptorSetLayout> descriptorSetLayout = DescriptorSetLayoutBuilder()
+ .addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT)
+ .build(vk, device);
- // Build descriptors for the storage image
- const auto descriptorSetLayout1 (DescriptorSetLayoutBuilder().addSingleBinding(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_SHADER_STAGE_COMPUTE_BIT)
- .build(vk, device));
- const Unique<VkDescriptorSet> descriptorSet1 (makeDescriptorSet(vk, device, *descriptorPool, *descriptorSetLayout1));
+ Move<VkImageView> storageImageImageView;
+ VkDescriptorImageInfo storageImageDscrInfo;
+ Move<VkDescriptorSet> storageImageDescriptorSet;
- const VkDescriptorImageInfo storageImageDscrInfo = makeDescriptorImageInfo(DE_NULL, *storageImageImageView, VK_IMAGE_LAYOUT_GENERAL);
- DescriptorSetUpdateBuilder().writeSingle(*descriptorSet1, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &storageImageDscrInfo)
- .update(vk, device);
+ // Cubemap tests use separate image views for each side of a cubemap.
+ vector<VkImageSubresourceRange> cubeSubresourceRanges;
+ vector<Move<VkImageView>> cubeStorageImageViews;
+ vector<VkDescriptorImageInfo> cubeStorageDscrImageInfos;
+ vector<Move<VkDescriptorSet>> cubeStorageDscrSets;
- // Create a compute pipeline
+ if (m_cubemap)
+ {
+ DescriptorSetUpdateBuilder updateBuilder;
+ for (int i = 0; i < FACES; i++)
+ {
+ cubeSubresourceRanges.emplace_back(makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1, i, 1));
+ cubeStorageImageViews.emplace_back(makeImageView(vk, device, *storageImage, VK_IMAGE_VIEW_TYPE_2D, m_imageViewFormat, cubeSubresourceRanges[i]));
+ cubeStorageDscrImageInfos.emplace_back(makeDescriptorImageInfo(DE_NULL, *cubeStorageImageViews[i], VK_IMAGE_LAYOUT_GENERAL));
+ cubeStorageDscrSets.emplace_back(makeDescriptorSet(vk, device, *descriptorPool, *descriptorSetLayout));
+ updateBuilder.writeSingle(*cubeStorageDscrSets[i], DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &cubeStorageDscrImageInfos[i]);
+ }
+ updateBuilder.update(vk, device);
+ }
+ else
+ {
+ storageImageImageView = makeImageView(vk, device, *storageImage, VK_IMAGE_VIEW_TYPE_2D, m_imageViewFormat, imageSubresourceRange);
+ storageImageDscrInfo = makeDescriptorImageInfo(DE_NULL, *storageImageImageView, VK_IMAGE_LAYOUT_GENERAL);
+ storageImageDescriptorSet = makeDescriptorSet(vk, device, *descriptorPool, *descriptorSetLayout);
+
+ DescriptorSetUpdateBuilder()
+ .writeSingle(*storageImageDescriptorSet, DescriptorSetUpdateBuilder::Location::binding(0u), VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, &storageImageDscrInfo)
+ .update(vk, device);
+ }
+
+ // Create a compute pipeline.
+ Move<VkShaderModule> computeShader = createShaderModule(vk, device, m_context.getBinaryCollection().get("comp"), 0u);
const VkPushConstantRange pushConstantRange =
{
VK_SHADER_STAGE_COMPUTE_BIT, // VkShaderStageFlags stageFlags;
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, storageImageViewSize.x(), storageImageViewSize.y(), 1u);
+ // If cubemaps are enabled, loop over six times and bind the next face of the cubemap image on each iteration.
+ if (m_cubemap)
+ {
+ for (int face = 0; face < FACES; face++)
+ {
+ vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipelineLayout, 0u, 1u, &(cubeStorageDscrSets[face].get()), 0u, DE_NULL);
- vk.cmdDispatch(*cmdBuffer, WIDTH, HEIGHT, 1u);
++ vk.cmdDispatch(*cmdBuffer, storageImageViewSize.x(), storageImageViewSize.y(), 1u);
+ }
+ }
+ else
+ {
+ vk.cmdBindDescriptorSets(*cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, *computePipelineLayout, 0u, 1u, &storageImageDescriptorSet.get(), 0u, DE_NULL);
- 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);
void SampleDrawnTextureTest::initPrograms (SourceCollections& programCollection) const
{
- // Pure blue and pure red compressed with the BC1 and BC3 algorithms.
- std::string bc1_red = " uvec4(4160813056u, 0u, 4160813056u, 0u);\n";
+ // Pure red, green, and blue compressed with the BC1 and BC3 algorithms.
+ std::string bc1_red = "uvec4(4160813056u, 0u, 4160813056u, 0u);\n";
std::string bc1_blue = "uvec4(2031647, 0u, 2031647, 0u);\n";
- std::string bc3_red = " uvec4(4294967295u, 4294967295u, 4160813056u, 0u);\n";
+ 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::string red = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_red : bc3_red;
+ std::string blue = (m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK) ? bc1_blue : bc3_blue;
+
std::ostringstream computeSrc;
- computeSrc
- << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
- << "layout(set = 0, binding = 0, rgba32ui) uniform highp uimage2D img;\n"
- << "layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n";
- if (!m_twoSamplers)
- {
- computeSrc
+
+ // Generate the compute shader.
+ computeSrc << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n";
+ computeSrc << "layout(set = 0, binding = 0, rgba32ui) uniform highp uimage2D img;\n";
+ computeSrc << "layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;\n";
+
+ if (!m_twoSamplers)
+ {
+ computeSrc
<< "layout(push_constant) uniform constants {\n"
- << " int pass;\n"
+ << " int pass;\n"
<< "} pc;\n";
- }
- computeSrc << "void main() {\n";
- if (m_twoSamplers)
- {
- computeSrc << " uvec4 color = ";
- m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK ? computeSrc << bc1_blue : computeSrc << bc3_blue;
- }
- else
- {
- computeSrc << " uvec4 color = ";
- m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK ? computeSrc << bc1_red : computeSrc << bc3_red;
+ }
- computeSrc << " if (pc.pass == 1) { \n";
- computeSrc << " color = ";
- m_imageFormat == VK_FORMAT_BC1_RGB_UNORM_BLOCK ? computeSrc << bc1_blue : computeSrc << bc3_blue;
- computeSrc << " }\n";
- }
- computeSrc
- << " imageStore(img, ivec2(gl_GlobalInvocationID.xy), color);\n"
- << "}\n";
+ computeSrc << "void main() {\n";
+
+ if (m_twoSamplers)
+ computeSrc << " uvec4 color = " << blue;
+ else
+ {
+ computeSrc << " uvec4 color = " << red;
+ computeSrc << " if (pc.pass == 1)\n";
+ computeSrc << " color = " << blue;
+ }
- << " for (int x = 0; x < " << WIDTH / blockSize.x() << "; x++)\n"
- << " for (int y = 0; y < " << HEIGHT / blockSize.y() << "; y++)\n"
- << " imageStore(img, ivec2(x, y), color);\n"
+ computeSrc
++ << " imageStore(img, ivec2(gl_GlobalInvocationID.xy), color);\n"
+ << "}\n";
+
+ // Generate the vertex shader.
std::ostringstream vertexSrc;
vertexSrc
<< glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
}
- m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
-
- if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED)
- m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
-
for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
{
+ m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
+
+ if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDEXED)
+ m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
+
+ bindResources();
+
if (m_useDynamicRendering)
{
+ addRenderingSubpassDependencyIfRequired(subpassNdx);
+
beginRendering(
*m_device,
*m_cmdBuffer,
cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
}
- m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
-
for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
{
+ m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
+
if (m_useDynamicRendering)
{
+ addRenderingSubpassDependencyIfRequired(subpassNdx);
+
beginRendering(
*m_device,
*m_cmdBuffer,
cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
}
- m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
-
for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
{
+ m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
+
if (m_useDynamicRendering)
{
+ addRenderingSubpassDependencyIfRequired(subpassNdx);
+
beginRendering(
*m_device,
*m_cmdBuffer,
cmdBeginRenderPass(*m_device, *m_cmdBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE, m_parameters.renderingType);
}
- m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
-
- if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
- m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
-
for (deUint32 subpassNdx = 0u; subpassNdx < subpassCount; subpassNdx++)
{
+ m_device->cmdBindVertexBuffers(*m_cmdBuffer, 0u, DE_LENGTH_OF_ARRAY(vertexBuffers), vertexBuffers, vertexBufferOffsets);
+
+ if (m_parameters.viewIndex == TEST_TYPE_DRAW_INDIRECT_INDEXED)
+ m_device->cmdBindIndexBuffer(*m_cmdBuffer, *m_vertexIndicesBuffer, 0u, VK_INDEX_TYPE_UINT32);
+
if (m_useDynamicRendering)
{
+ addRenderingSubpassDependencyIfRequired(subpassNdx);
+
beginRendering(
*m_device,
*m_cmdBuffer,