// Geometry shader
{
- const int maxVertices = (params.testType == TEST_TYPE_DIFFERENT_CONTENT) ? (params.image.numLayers + 1) * params.image.numLayers :
- (params.testType == TEST_TYPE_ALL_LAYERS || params.testType == TEST_TYPE_LAYER_ID) ? params.image.numLayers * 4 :
- (params.testType == TEST_TYPE_MULTIPLE_LAYERS_PER_INVOCATION) ? 6 : 4;
+ const int numLayers = static_cast<int>(params.image.viewType == VK_IMAGE_VIEW_TYPE_3D ? params.image.size.depth : params.image.numLayers);
+
+ const int maxVertices = (params.testType == TEST_TYPE_DIFFERENT_CONTENT) ? (numLayers + 1) * numLayers :
+ (params.testType == TEST_TYPE_ALL_LAYERS || params.testType == TEST_TYPE_LAYER_ID) ? numLayers * 4 :
+ (params.testType == TEST_TYPE_MULTIPLE_LAYERS_PER_INVOCATION) ? 6 : 4;
std::ostringstream src;
src << glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_450) << "\n"
<< "\n";
if (params.testType == TEST_TYPE_INVOCATION_PER_LAYER || params.testType == TEST_TYPE_MULTIPLE_LAYERS_PER_INVOCATION)
- src << "layout(points, invocations = " << params.image.numLayers << ") in;\n";
+ src << "layout(points, invocations = " << numLayers << ") in;\n";
else
src << "layout(points) in;\n";
{
src << colorTable.str()
<< "\n"
- << " for (int layerNdx = 0; layerNdx < " << params.image.numLayers << "; ++layerNdx) {\n"
+ << " for (int layerNdx = 0; layerNdx < " << numLayers << "; ++layerNdx) {\n"
<< " const int colorNdx = layerNdx % " << DE_LENGTH_OF_ARRAY(s_colors) << ";\n"
<< "\n"
<< " gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
}
else if (params.testType == TEST_TYPE_LAYER_ID)
{
- src << " for (int layerNdx = 0; layerNdx < " << params.image.numLayers << "; ++layerNdx) {\n"
+ src << " for (int layerNdx = 0; layerNdx < " << numLayers << "; ++layerNdx) {\n"
<< " gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
<< " gl_Layer = layerNdx;\n"
<< " EmitVertex();\n"
}
else if (params.testType == TEST_TYPE_DIFFERENT_CONTENT)
{
- src << " for (int layerNdx = 0; layerNdx < " << params.image.numLayers << "; ++layerNdx) {\n"
+ src << " for (int layerNdx = 0; layerNdx < " << numLayers << "; ++layerNdx) {\n"
<< " for (int colNdx = 0; colNdx <= layerNdx; ++colNdx) {\n"
- << " const float posX = float(colNdx) / float(" << params.image.numLayers << ") * 2.0 - 1.0;\n"
+ << " const float posX = float(colNdx) / float(" << numLayers << ") * 2.0 - 1.0;\n"
<< "\n"
<< " gl_Position = vec4(posX, 1.0, 0.0, 1.0);\n"
<< " gl_Layer = layerNdx;\n"
else if (params.testType == TEST_TYPE_MULTIPLE_LAYERS_PER_INVOCATION)
{
src << " const int layerA = gl_InvocationID;\n"
- << " const int layerB = (gl_InvocationID + 1) % " << params.image.numLayers << ";\n"
- << " const float aEnd = float(layerA) / float(" << params.image.numLayers << ") * 2.0 - 1.0;\n"
- << " const float bEnd = float(layerB) / float(" << params.image.numLayers << ") * 2.0 - 1.0;\n"
+ << " const int layerB = (gl_InvocationID + 1) % " << numLayers << ";\n"
+ << " const float aEnd = float(layerA) / float(" << numLayers << ") * 2.0 - 1.0;\n"
+ << " const float bEnd = float(layerB) / float(" << numLayers << ") * 2.0 - 1.0;\n"
<< "\n"
<< " gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);\n"
<< " gl_Layer = layerA;\n"
tcu::TestStatus test (Context& context, const TestParams params)
{
- const DeviceInterface& vk = context.getDeviceInterface();
- const InstanceInterface& vki = context.getInstanceInterface();
- const VkDevice device = context.getDevice();
- const VkPhysicalDevice physDevice = context.getPhysicalDevice();
- const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
- const VkQueue queue = context.getUniversalQueue();
- Allocator& allocator = context.getDefaultAllocator();
+ if (VK_IMAGE_VIEW_TYPE_3D == params.image.viewType &&
+ (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_maintenance1")))
+ TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance1 not supported");
+
+ const DeviceInterface& vk = context.getDeviceInterface();
+ const InstanceInterface& vki = context.getInstanceInterface();
+ const VkDevice device = context.getDevice();
+ const VkPhysicalDevice physDevice = context.getPhysicalDevice();
+ const deUint32 queueFamilyIndex = context.getUniversalQueueFamilyIndex();
+ const VkQueue queue = context.getUniversalQueue();
+ Allocator& allocator = context.getDefaultAllocator();
checkGeometryShaderSupport(vki, physDevice);
const VkFormat colorFormat = VK_FORMAT_R8G8B8A8_UNORM;
- const VkImageSubresourceRange colorSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, params.image.numLayers);
+ const deUint32 numLayers = (VK_IMAGE_VIEW_TYPE_3D == params.image.viewType ? params.image.size.depth : params.image.numLayers);
const Vec4 clearColor = Vec4(0.0f, 0.0f, 0.0f, 1.0f);
const VkDeviceSize colorBufferSize = params.image.size.width * params.image.size.height * params.image.size.depth * params.image.numLayers * tcu::getPixelSize(mapVkFormat(colorFormat));
- const VkImageCreateFlags imageCreateFlags = (isCubeImageViewType(params.image.viewType) ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : (VkImageCreateFlagBits)0);
-
- const Unique<VkImage> colorImage (makeImage (vk, device, makeImageCreateInfo(imageCreateFlags, getImageType(params.image.viewType), colorFormat, params.image.size,
- params.image.numLayers, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT)));
- const UniquePtr<Allocation> colorImageAlloc (bindImage (vk, device, allocator, *colorImage, MemoryRequirement::Any));
- const Unique<VkImageView> colorAttachment (makeImageView (vk, device, *colorImage, params.image.viewType, colorFormat, colorSubresourceRange));
- const Unique<VkBuffer> colorBuffer (makeBuffer (vk, device, makeBufferCreateInfo(colorBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT)));
- const UniquePtr<Allocation> colorBufferAlloc (bindBuffer (vk, device, allocator, *colorBuffer, MemoryRequirement::HostVisible));
-
- const Unique<VkShaderModule> vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u));
- const Unique<VkShaderModule> geometryModule (createShaderModule (vk, device, context.getBinaryCollection().get("geom"), 0u));
- const Unique<VkShaderModule> fragmentModule (createShaderModule (vk, device, context.getBinaryCollection().get("frag"), 0u));
-
- const Unique<VkRenderPass> renderPass (makeRenderPass (vk, device, colorFormat));
- const Unique<VkFramebuffer> framebuffer (makeFramebuffer (vk, device, *renderPass, *colorAttachment, params.image.size.width, params.image.size.height, params.image.numLayers));
- const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout (vk, device));
- const Unique<VkPipeline> pipeline (makeGraphicsPipeline (vk, device, *pipelineLayout, *renderPass, *vertexModule, *geometryModule, *fragmentModule,
- makeExtent2D(params.image.size.width, params.image.size.height)));
- const Unique<VkCommandPool> cmdPool (makeCommandPool (vk, device, queueFamilyIndex));
- const Unique<VkCommandBuffer> cmdBuffer (makeCommandBuffer (vk, device, *cmdPool));
+ const VkImageCreateFlags imageCreateFlags = (isCubeImageViewType(params.image.viewType) ? VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT : (VkImageCreateFlagBits)0) |
+ (VK_IMAGE_VIEW_TYPE_3D == params.image.viewType ? VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR : (VkImageCreateFlagBits)0);
+ const VkImageViewType viewType = (VK_IMAGE_VIEW_TYPE_3D == params.image.viewType ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : params.image.viewType);
+
+ const Unique<VkImage> colorImage (makeImage (vk, device, makeImageCreateInfo(imageCreateFlags, getImageType(params.image.viewType), colorFormat, params.image.size,
+ params.image.numLayers, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT)));
+ const UniquePtr<Allocation> colorImageAlloc (bindImage (vk, device, allocator, *colorImage, MemoryRequirement::Any));
+ const Unique<VkImageView> colorAttachment (makeImageView (vk, device, *colorImage, viewType, colorFormat, makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, numLayers)));
+
+ const Unique<VkBuffer> colorBuffer (makeBuffer (vk, device, makeBufferCreateInfo(colorBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT)));
+ const UniquePtr<Allocation> colorBufferAlloc (bindBuffer (vk, device, allocator, *colorBuffer, MemoryRequirement::HostVisible));
+
+ const Unique<VkShaderModule> vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u));
+ const Unique<VkShaderModule> geometryModule (createShaderModule (vk, device, context.getBinaryCollection().get("geom"), 0u));
+ const Unique<VkShaderModule> fragmentModule (createShaderModule (vk, device, context.getBinaryCollection().get("frag"), 0u));
+
+ const Unique<VkRenderPass> renderPass (makeRenderPass (vk, device, colorFormat));
+ const Unique<VkFramebuffer> framebuffer (makeFramebuffer (vk, device, *renderPass, *colorAttachment, params.image.size.width, params.image.size.height, numLayers));
+ const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout (vk, device));
+ const Unique<VkPipeline> pipeline (makeGraphicsPipeline (vk, device, *pipelineLayout, *renderPass, *vertexModule, *geometryModule, *fragmentModule,
+ makeExtent2D(params.image.size.width, params.image.size.height)));
+ const Unique<VkCommandPool> cmdPool (makeCommandPool (vk, device, queueFamilyIndex));
+ const Unique<VkCommandBuffer> cmdBuffer (makeCommandBuffer (vk, device, *cmdPool));
zeroBuffer(vk, device, *colorBufferAlloc, colorBufferSize);
// Prepare color image for copy
{
- const VkImageMemoryBarrier barriers[] =
+ const VkImageSubresourceRange colorSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, params.image.numLayers);
+ const VkImageMemoryBarrier barriers[] =
{
{
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType;
const ImageParams imageParams[] =
{
- { VK_IMAGE_VIEW_TYPE_1D_ARRAY, { 64, 1, 1 }, 4 },
- { VK_IMAGE_VIEW_TYPE_2D_ARRAY, { 64, 64, 1 }, 4 },
- { VK_IMAGE_VIEW_TYPE_CUBE, { 64, 64, 1 }, 6 },
- { VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, { 64, 64, 1 }, 2*6 },
- // No support for rendering to 3d image slices in Vulkan 1.0
+ { VK_IMAGE_VIEW_TYPE_1D_ARRAY, { 64, 1, 1 }, 4 },
+ { VK_IMAGE_VIEW_TYPE_2D_ARRAY, { 64, 64, 1 }, 4 },
+ { VK_IMAGE_VIEW_TYPE_CUBE, { 64, 64, 1 }, 6 },
+ { VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, { 64, 64, 1 }, 2*6 },
+ { VK_IMAGE_VIEW_TYPE_3D, { 64, 64, 8 }, 1 }
};
for (int imageParamNdx = 0; imageParamNdx < DE_LENGTH_OF_ARRAY(imageParams); ++imageParamNdx)
tcu::TestStatus test (Context& context, const CaseDef caseDef)
{
+ if (VK_IMAGE_VIEW_TYPE_3D == caseDef.imageType &&
+ (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_maintenance1")))
+ TCU_THROW(NotSupportedError, "Extension VK_KHR_maintenance1 not supported");
+
const DeviceInterface& vk = context.getDeviceInterface();
const VkDevice device = context.getDevice();
const VkQueue queue = context.getUniversalQueue();
Vec4(0.1f, 0.0f, 1.0f, 1.0f)
};
+ const int numLayers = (VK_IMAGE_VIEW_TYPE_3D == caseDef.imageType ? caseDef.renderSize.z() : caseDef.numLayers);
const VkDeviceSize colorBufferSize = caseDef.renderSize.x() * caseDef.renderSize.y() * caseDef.renderSize.z() * caseDef.numLayers * tcu::getPixelSize(mapVkFormat(caseDef.colorFormat));
const Unique<VkBuffer> colorBuffer (makeBuffer(vk, device, colorBufferSize, VK_BUFFER_USAGE_TRANSFER_DST_BIT));
const UniquePtr<Allocation> colorBufferAlloc (bindBuffer(vk, device, allocator, *colorBuffer, MemoryRequirement::HostVisible));
const Unique<VkShaderModule> vertexModule (createShaderModule (vk, device, context.getBinaryCollection().get("vert"), 0u));
const Unique<VkShaderModule> fragmentModule (createShaderModule (vk, device, context.getBinaryCollection().get("frag"), 0u));
- const Unique<VkRenderPass> renderPass (makeRenderPass (vk, device, caseDef.colorFormat, static_cast<deUint32>(caseDef.numLayers)));
+ const Unique<VkRenderPass> renderPass (makeRenderPass (vk, device, caseDef.colorFormat, static_cast<deUint32>(numLayers)));
const Unique<VkPipelineLayout> pipelineLayout (makePipelineLayout (vk, device));
vector<SharedPtrVkPipeline> pipeline;
const Unique<VkCommandPool> cmdPool (makeCommandPool (vk, device, queueFamilyIndex));
//create colorImage
{
+ const VkImageViewCreateFlags flags = (VK_IMAGE_VIEW_TYPE_3D == caseDef.imageType ? (VkImageViewCreateFlags)VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR : (VkImageViewCreateFlags)0);
const VkImageUsageFlags colorImageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
- colorImage = makeImage(vk, device, VkImageViewCreateFlags(0), getImageType(caseDef.imageType), caseDef.colorFormat, caseDef.renderSize, caseDef.numLayers, colorImageUsage);
+ colorImage = makeImage(vk, device, flags, getImageType(caseDef.imageType), caseDef.colorFormat, caseDef.renderSize, caseDef.numLayers, colorImageUsage);
colorImageAlloc = bindImage(vk, device, allocator, *colorImage, MemoryRequirement::Any);
}
//create vertexBuffer
{
- const vector<Vertex4RGBA> vertices = genFullQuadVertices(caseDef.numLayers, vector<Vec4>(color, color + DE_LENGTH_OF_ARRAY(color)));
+ const vector<Vertex4RGBA> vertices = genFullQuadVertices(numLayers, vector<Vec4>(color, color + DE_LENGTH_OF_ARRAY(color)));
const VkDeviceSize vertexBufferSize = sizeInBytes(vertices);
vertexBuffer = makeBuffer(vk, device, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
}
//create attachmentHandles and pipelines
- for (int layerNdx = 0; layerNdx < caseDef.numLayers; ++layerNdx)
+ for (int layerNdx = 0; layerNdx < numLayers; ++layerNdx)
{
- colorAttachments.push_back(makeSharedPtr(makeImageView(vk, device, *colorImage,
- (caseDef.imageType == VK_IMAGE_VIEW_TYPE_CUBE || caseDef.imageType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY ? VK_IMAGE_VIEW_TYPE_2D : caseDef.imageType),
- caseDef.colorFormat, makeColorSubresourceRange(layerNdx, 1))));
+ const VkImageViewType imageType = (VK_IMAGE_VIEW_TYPE_3D == caseDef.imageType ? VK_IMAGE_VIEW_TYPE_2D_ARRAY :
+ (VK_IMAGE_VIEW_TYPE_CUBE == caseDef.imageType || VK_IMAGE_VIEW_TYPE_CUBE_ARRAY == caseDef.imageType ? VK_IMAGE_VIEW_TYPE_2D :
+ caseDef.imageType));
+
+ colorAttachments.push_back(makeSharedPtr(makeImageView(vk, device, *colorImage, imageType, caseDef.colorFormat, makeColorSubresourceRange(layerNdx, 1))));
attachmentHandles.push_back(**colorAttachments.back());
pipeline.push_back(makeSharedPtr(makeGraphicsPipeline(vk, device, *pipelineLayout, *renderPass, *vertexModule, *fragmentModule,
caseDef.renderSize, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, static_cast<deUint32>(layerNdx))));
}
- framebuffer = makeFramebuffer(vk, device, *renderPass, caseDef.numLayers, &attachmentHandles[0], static_cast<deUint32>(caseDef.renderSize.x()), static_cast<deUint32>(caseDef.renderSize.y()));
+ framebuffer = makeFramebuffer(vk, device, *renderPass, numLayers, &attachmentHandles[0], static_cast<deUint32>(caseDef.renderSize.x()), static_cast<deUint32>(caseDef.renderSize.y()));
beginCommandBuffer(vk, *cmdBuffer);
{
- const vector<VkClearValue> clearValues (caseDef.numLayers, getClearValue(caseDef.colorFormat));
+ const vector<VkClearValue> clearValues (numLayers, getClearValue(caseDef.colorFormat));
const VkRect2D renderArea =
{
makeOffset2D(0, 0),
}
//cmdDraw
- for (deUint32 layerNdx = 0; layerNdx < static_cast<deUint32>(caseDef.numLayers); ++layerNdx)
+ for (deUint32 layerNdx = 0; layerNdx < static_cast<deUint32>(numLayers); ++layerNdx)
{
if (layerNdx != 0)
vk.cmdNextSubpass(*cmdBuffer, VK_SUBPASS_CONTENTS_INLINE);
{ VK_IMAGE_VIEW_TYPE_1D_ARRAY, IVec3(54, 1, 1), 4, VK_FORMAT_UNDEFINED},
{ VK_IMAGE_VIEW_TYPE_2D, IVec3(22, 64, 1), 1, VK_FORMAT_UNDEFINED},
{ VK_IMAGE_VIEW_TYPE_2D_ARRAY, IVec3(22, 64, 1), 4, VK_FORMAT_UNDEFINED},
+ { VK_IMAGE_VIEW_TYPE_3D, IVec3(22, 64, 7), 1, VK_FORMAT_UNDEFINED},
{ VK_IMAGE_VIEW_TYPE_CUBE, IVec3(35, 35, 1), 6, VK_FORMAT_UNDEFINED},
{ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, IVec3(35, 35, 1), 2*6, VK_FORMAT_UNDEFINED},
};