vk: Implement Multipass

This commit is contained in:
Jason Ekstrand 2015-07-10 20:18:52 -07:00
parent 68768c40be
commit 8478350992
6 changed files with 608 additions and 369 deletions

View File

@ -31,7 +31,7 @@ extern "C" {
/* /*
** This header is generated from the Khronos Vulkan XML API Registry. ** This header is generated from the Khronos Vulkan XML API Registry.
** **
** Generated on date 20150620 ** Generated on date 20150624
*/ */
@ -42,7 +42,7 @@ extern "C" {
((major << 22) | (minor << 12) | patch) ((major << 22) | (minor << 12) | patch)
// Vulkan API version supported by this file // Vulkan API version supported by this file
#define VK_API_VERSION VK_MAKE_VERSION(0, 130, 0) #define VK_API_VERSION VK_MAKE_VERSION(0, 131, 0)
#if defined (__cplusplus) && (VK_UINTPTRLEAST64_MAX == UINTPTR_MAX) #if defined (__cplusplus) && (VK_UINTPTRLEAST64_MAX == UINTPTR_MAX)
#define VK_TYPE_SAFE_COMPATIBLE_HANDLES 1 #define VK_TYPE_SAFE_COMPATIBLE_HANDLES 1
@ -71,6 +71,7 @@ extern "C" {
#define VK_LAST_MIP_LEVEL UINT32_MAX #define VK_LAST_MIP_LEVEL UINT32_MAX
#define VK_LAST_ARRAY_SLICE UINT32_MAX #define VK_LAST_ARRAY_SLICE UINT32_MAX
#define VK_WHOLE_SIZE UINT64_MAX #define VK_WHOLE_SIZE UINT64_MAX
#define VK_ATTACHMENT_UNUSED UINT32_MAX
#define VK_TRUE 1 #define VK_TRUE 1
#define VK_FALSE 0 #define VK_FALSE 0
#define VK_NULL_HANDLE 0 #define VK_NULL_HANDLE 0
@ -91,8 +92,7 @@ VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkEvent, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkQueryPool, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkQueryPool, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkBufferView, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkBufferView, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkImageView, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkImageView, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkColorAttachmentView, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkAttachmentView, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkDepthStencilView, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkShaderModule, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkShaderModule, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkShader, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkShader, VkNonDispatchable)
VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkPipelineCache, VkNonDispatchable) VK_DEFINE_NONDISP_SUBCLASS_HANDLE(VkPipelineCache, VkNonDispatchable)
@ -161,52 +161,55 @@ typedef enum {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 1, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 1,
VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO = 2, VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO = 2,
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3,
VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO = 4, VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO = 4,
VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO = 5, VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 5,
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 6, VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 6,
VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 7, VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 7,
VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 8, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 8,
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 9, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 9,
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 10, VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO = 10,
VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO = 11, VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO = 11,
VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO = 12, VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO = 12,
VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO = 13, VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO = 13,
VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO = 14, VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO = 14,
VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO = 15, VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 15,
VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 16, VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 16,
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 17, VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 17,
VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 18, VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 18,
VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 19, VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 19,
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 20, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 20,
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 21, VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 21,
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 22, VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO = 22,
VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO = 23, VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO = 23,
VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO = 24, VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO = 24,
VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO = 25, VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO = 25,
VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO = 26, VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO = 26,
VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO = 27, VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO = 27,
VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO = 28, VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO = 28,
VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO = 29, VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 29,
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 30, VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 30,
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 31, VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 31,
VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 32, VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 32,
VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 33, VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO = 33,
VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO = 34, VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 34,
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 35, VK_STRUCTURE_TYPE_LAYER_CREATE_INFO = 35,
VK_STRUCTURE_TYPE_LAYER_CREATE_INFO = 36, VK_STRUCTURE_TYPE_MEMORY_BARRIER = 36,
VK_STRUCTURE_TYPE_MEMORY_BARRIER = 37, VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 37,
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 38, VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 38,
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 39, VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 39,
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 40, VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 40,
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 41, VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 41,
VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 42, VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 42,
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 43, VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 43,
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 44, VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 44,
VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 45, VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 45,
VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 46, VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION = 46,
VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION = 47,
VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY = 48,
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 49,
VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO,
VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO, VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), VK_STRUCTURE_TYPE_NUM = (VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1),
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType; } VkStructureType;
@ -445,27 +448,26 @@ typedef enum {
VK_OBJECT_TYPE_BUFFER_VIEW = 7, VK_OBJECT_TYPE_BUFFER_VIEW = 7,
VK_OBJECT_TYPE_IMAGE = 8, VK_OBJECT_TYPE_IMAGE = 8,
VK_OBJECT_TYPE_IMAGE_VIEW = 9, VK_OBJECT_TYPE_IMAGE_VIEW = 9,
VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW = 10, VK_OBJECT_TYPE_ATTACHMENT_VIEW = 10,
VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW = 11, VK_OBJECT_TYPE_SHADER_MODULE = 11,
VK_OBJECT_TYPE_SHADER_MODULE = 12, VK_OBJECT_TYPE_SHADER = 12,
VK_OBJECT_TYPE_SHADER = 13, VK_OBJECT_TYPE_PIPELINE = 13,
VK_OBJECT_TYPE_PIPELINE = 14, VK_OBJECT_TYPE_PIPELINE_LAYOUT = 14,
VK_OBJECT_TYPE_PIPELINE_LAYOUT = 15, VK_OBJECT_TYPE_SAMPLER = 15,
VK_OBJECT_TYPE_SAMPLER = 16, VK_OBJECT_TYPE_DESCRIPTOR_SET = 16,
VK_OBJECT_TYPE_DESCRIPTOR_SET = 17, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 17,
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 18, VK_OBJECT_TYPE_DESCRIPTOR_POOL = 18,
VK_OBJECT_TYPE_DESCRIPTOR_POOL = 19, VK_OBJECT_TYPE_DYNAMIC_VP_STATE = 19,
VK_OBJECT_TYPE_DYNAMIC_VP_STATE = 20, VK_OBJECT_TYPE_DYNAMIC_RS_STATE = 20,
VK_OBJECT_TYPE_DYNAMIC_RS_STATE = 21, VK_OBJECT_TYPE_DYNAMIC_CB_STATE = 21,
VK_OBJECT_TYPE_DYNAMIC_CB_STATE = 22, VK_OBJECT_TYPE_DYNAMIC_DS_STATE = 22,
VK_OBJECT_TYPE_DYNAMIC_DS_STATE = 23, VK_OBJECT_TYPE_FENCE = 23,
VK_OBJECT_TYPE_FENCE = 24, VK_OBJECT_TYPE_SEMAPHORE = 24,
VK_OBJECT_TYPE_SEMAPHORE = 25, VK_OBJECT_TYPE_EVENT = 25,
VK_OBJECT_TYPE_EVENT = 26, VK_OBJECT_TYPE_QUERY_POOL = 26,
VK_OBJECT_TYPE_QUERY_POOL = 27, VK_OBJECT_TYPE_FRAMEBUFFER = 27,
VK_OBJECT_TYPE_FRAMEBUFFER = 28, VK_OBJECT_TYPE_RENDER_PASS = 28,
VK_OBJECT_TYPE_RENDER_PASS = 29, VK_OBJECT_TYPE_PIPELINE_CACHE = 29,
VK_OBJECT_TYPE_PIPELINE_CACHE = 30,
VK_OBJECT_TYPE_BEGIN_RANGE = VK_OBJECT_TYPE_INSTANCE, VK_OBJECT_TYPE_BEGIN_RANGE = VK_OBJECT_TYPE_INSTANCE,
VK_OBJECT_TYPE_END_RANGE = VK_OBJECT_TYPE_PIPELINE_CACHE, VK_OBJECT_TYPE_END_RANGE = VK_OBJECT_TYPE_PIPELINE_CACHE,
VK_OBJECT_TYPE_NUM = (VK_OBJECT_TYPE_PIPELINE_CACHE - VK_OBJECT_TYPE_INSTANCE + 1), VK_OBJECT_TYPE_NUM = (VK_OBJECT_TYPE_PIPELINE_CACHE - VK_OBJECT_TYPE_INSTANCE + 1),
@ -743,9 +745,10 @@ typedef enum {
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9,
VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10,
VK_DESCRIPTOR_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_TYPE_SAMPLER,
VK_DESCRIPTOR_TYPE_END_RANGE = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, VK_DESCRIPTOR_TYPE_END_RANGE = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
VK_DESCRIPTOR_TYPE_NUM = (VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC - VK_DESCRIPTOR_TYPE_SAMPLER + 1), VK_DESCRIPTOR_TYPE_NUM = (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - VK_DESCRIPTOR_TYPE_SAMPLER + 1),
VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkDescriptorType; } VkDescriptorType;
@ -998,10 +1001,10 @@ typedef enum {
typedef VkFlags VkImageCreateFlags; typedef VkFlags VkImageCreateFlags;
typedef enum { typedef enum {
VK_DEPTH_STENCIL_VIEW_CREATE_READ_ONLY_DEPTH_BIT = 0x00000001, VK_ATTACHMENT_VIEW_CREATE_READ_ONLY_DEPTH_BIT = 0x00000001,
VK_DEPTH_STENCIL_VIEW_CREATE_READ_ONLY_STENCIL_BIT = 0x00000002, VK_ATTACHMENT_VIEW_CREATE_READ_ONLY_STENCIL_BIT = 0x00000002,
} VkDepthStencilViewCreateFlagBits; } VkAttachmentViewCreateFlagBits;
typedef VkFlags VkDepthStencilViewCreateFlags; typedef VkFlags VkAttachmentViewCreateFlags;
typedef VkFlags VkShaderModuleCreateFlags; typedef VkFlags VkShaderModuleCreateFlags;
typedef VkFlags VkShaderCreateFlags; typedef VkFlags VkShaderCreateFlags;
@ -1031,6 +1034,11 @@ typedef enum {
} VkShaderStageFlagBits; } VkShaderStageFlagBits;
typedef VkFlags VkShaderStageFlags; typedef VkFlags VkShaderStageFlags;
typedef enum {
VK_SUBPASS_DESCRIPTION_NO_OVERDRAW_BIT = 0x00000001,
} VkSubpassDescriptionFlagBits;
typedef VkFlags VkSubpassDescriptionFlags;
typedef enum { typedef enum {
VK_PIPE_EVENT_TOP_OF_PIPE_BIT = 0x00000001, VK_PIPE_EVENT_TOP_OF_PIPE_BIT = 0x00000001,
VK_PIPE_EVENT_VERTEX_PROCESSING_COMPLETE_BIT = 0x00000002, VK_PIPE_EVENT_VERTEX_PROCESSING_COMPLETE_BIT = 0x00000002,
@ -1062,7 +1070,8 @@ typedef enum {
VK_MEMORY_INPUT_SHADER_READ_BIT = 0x00000020, VK_MEMORY_INPUT_SHADER_READ_BIT = 0x00000020,
VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT = 0x00000040, VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT = 0x00000040,
VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000080, VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000080,
VK_MEMORY_INPUT_TRANSFER_BIT = 0x00000100, VK_MEMORY_INPUT_INPUT_ATTACHMENT_BIT = 0x00000100,
VK_MEMORY_INPUT_TRANSFER_BIT = 0x00000200,
} VkMemoryInputFlagBits; } VkMemoryInputFlagBits;
typedef VkFlags VkMemoryInputFlags; typedef VkFlags VkMemoryInputFlags;
typedef VkFlags VkCmdBufferCreateFlags; typedef VkFlags VkCmdBufferCreateFlags;
@ -1465,19 +1474,8 @@ typedef struct {
uint32_t mipLevel; uint32_t mipLevel;
uint32_t baseArraySlice; uint32_t baseArraySlice;
uint32_t arraySize; uint32_t arraySize;
VkImage msaaResolveImage; VkAttachmentViewCreateFlags flags;
VkImageSubresourceRange msaaResolveSubResource; } VkAttachmentViewCreateInfo;
} VkColorAttachmentViewCreateInfo;
typedef struct {
VkStructureType sType;
const void* pNext;
VkImage image;
uint32_t mipLevel;
uint32_t baseArraySlice;
uint32_t arraySize;
VkDepthStencilViewCreateFlags flags;
} VkDepthStencilViewCreateInfo;
typedef struct { typedef struct {
VkStructureType sType; VkStructureType sType;
@ -1592,7 +1590,6 @@ typedef struct {
typedef struct { typedef struct {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkFormat format;
VkBool32 depthTestEnable; VkBool32 depthTestEnable;
VkBool32 depthWriteEnable; VkBool32 depthWriteEnable;
VkCompareOp depthCompareOp; VkCompareOp depthCompareOp;
@ -1604,7 +1601,6 @@ typedef struct {
typedef struct { typedef struct {
VkBool32 blendEnable; VkBool32 blendEnable;
VkFormat format;
VkBlend srcBlendColor; VkBlend srcBlendColor;
VkBlend destBlendColor; VkBlend destBlendColor;
VkBlendOp blendOpColor; VkBlendOp blendOpColor;
@ -1639,6 +1635,8 @@ typedef struct {
const VkPipelineCbStateCreateInfo* pCbState; const VkPipelineCbStateCreateInfo* pCbState;
VkPipelineCreateFlags flags; VkPipelineCreateFlags flags;
VkPipelineLayout layout; VkPipelineLayout layout;
VkRenderPass renderPass;
uint32_t subpass;
VkPipeline basePipelineHandle; VkPipeline basePipelineHandle;
int32_t basePipelineIndex; int32_t basePipelineIndex;
} VkGraphicsPipelineCreateInfo; } VkGraphicsPipelineCreateInfo;
@ -1716,6 +1714,7 @@ typedef struct {
VkBufferView bufferView; VkBufferView bufferView;
VkSampler sampler; VkSampler sampler;
VkImageView imageView; VkImageView imageView;
VkAttachmentView attachmentView;
VkImageLayout imageLayout; VkImageLayout imageLayout;
} VkDescriptorInfo; } VkDescriptorInfo;
@ -1801,54 +1800,74 @@ typedef struct {
} VkDynamicDepthStencilStateCreateInfo; } VkDynamicDepthStencilStateCreateInfo;
typedef struct { typedef struct {
VkColorAttachmentView view; VkAttachmentView view;
VkImageLayout layout; VkImageLayout layout;
} VkColorAttachmentBindInfo; } VkAttachmentBindInfo;
typedef struct {
VkDepthStencilView view;
VkImageLayout layout;
} VkDepthStencilBindInfo;
typedef struct { typedef struct {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
uint32_t colorAttachmentCount; VkRenderPass renderPass;
const VkColorAttachmentBindInfo* pColorAttachments; uint32_t attachmentCount;
const VkDepthStencilBindInfo* pDepthStencilAttachment; const VkAttachmentBindInfo* pAttachments;
uint32_t sampleCount;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
uint32_t layers; uint32_t layers;
} VkFramebufferCreateInfo; } VkFramebufferCreateInfo;
typedef union { typedef struct {
float f32[4]; VkStructureType sType;
int32_t s32[4]; const void* pNext;
uint32_t u32[4]; VkFormat format;
} VkClearColorValue; uint32_t samples;
VkAttachmentLoadOp loadOp;
VkAttachmentStoreOp storeOp;
VkAttachmentLoadOp stencilLoadOp;
VkAttachmentStoreOp stencilStoreOp;
VkImageLayout initialLayout;
VkImageLayout finalLayout;
} VkAttachmentDescription;
typedef struct {
uint32_t attachment;
VkImageLayout layout;
} VkAttachmentReference;
typedef struct { typedef struct {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkRect2D renderArea; VkPipelineBindPoint pipelineBindPoint;
uint32_t colorAttachmentCount; VkSubpassDescriptionFlags flags;
VkExtent2D extent; uint32_t inputCount;
uint32_t sampleCount; const VkAttachmentReference* inputAttachments;
uint32_t layers; uint32_t colorCount;
const VkFormat* pColorFormats; const VkAttachmentReference* colorAttachments;
const VkImageLayout* pColorLayouts; const VkAttachmentReference* resolveAttachments;
const VkAttachmentLoadOp* pColorLoadOps; VkAttachmentReference depthStencilAttachment;
const VkAttachmentStoreOp* pColorStoreOps; uint32_t preserveCount;
const VkClearColorValue* pColorLoadClearValues; const VkAttachmentReference* preserveAttachments;
VkFormat depthStencilFormat; } VkSubpassDescription;
VkImageLayout depthStencilLayout;
VkAttachmentLoadOp depthLoadOp; typedef struct {
float depthLoadClearValue; VkStructureType sType;
VkAttachmentStoreOp depthStoreOp; const void* pNext;
VkAttachmentLoadOp stencilLoadOp; uint32_t srcSubpass;
uint32_t stencilLoadClearValue; uint32_t dstSubpass;
VkAttachmentStoreOp stencilStoreOp; VkWaitEvent waitEvent;
VkPipeEventFlags pipeEventMask;
VkMemoryOutputFlags outputMask;
VkMemoryInputFlags inputMask;
} VkSubpassDependency;
typedef struct {
VkStructureType sType;
const void* pNext;
uint32_t attachmentCount;
const VkAttachmentDescription* pAttachments;
uint32_t subpassCount;
const VkSubpassDescription* pSubpasses;
uint32_t dependencyCount;
const VkSubpassDependency* pDependencies;
} VkRenderPassCreateInfo; } VkRenderPassCreateInfo;
typedef struct { typedef struct {
@ -1899,6 +1918,12 @@ typedef struct {
VkExtent3D imageExtent; VkExtent3D imageExtent;
} VkBufferImageCopy; } VkBufferImageCopy;
typedef union {
float f32[4];
int32_t s32[4];
uint32_t u32[4];
} VkClearColorValue;
typedef struct { typedef struct {
VkOffset3D offset; VkOffset3D offset;
VkExtent3D extent; VkExtent3D extent;
@ -1913,10 +1938,24 @@ typedef struct {
} VkImageResolve; } VkImageResolve;
typedef struct { typedef struct {
float depth;
uint32_t stencil;
} VkClearDepthStencilValue;
typedef union {
VkClearColorValue color;
VkClearDepthStencilValue ds;
} VkClearValue;
typedef struct {
VkStructureType sType;
const void* pNext;
VkRenderPass renderPass; VkRenderPass renderPass;
VkFramebuffer framebuffer; VkFramebuffer framebuffer;
VkRenderPassContents contents; VkRect2D renderArea;
} VkRenderPassBegin; uint32_t attachmentCount;
const VkClearValue* pAttachmentClearValues;
} VkRenderPassBeginInfo;
typedef struct { typedef struct {
VkStructureType sType; VkStructureType sType;
@ -2034,11 +2073,9 @@ typedef VkResult (VKAPI *PFN_vkCreateImage)(VkDevice device, const VkImageCreate
typedef VkResult (VKAPI *PFN_vkDestroyImage)(VkDevice device, VkImage image); typedef VkResult (VKAPI *PFN_vkDestroyImage)(VkDevice device, VkImage image);
typedef VkResult (VKAPI *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); typedef VkResult (VKAPI *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout);
typedef VkResult (VKAPI *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView); typedef VkResult (VKAPI *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView);
typedef VkResult (VKAPI *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView); typedef VkResult (VKAPI *PFN_vkDestroyImageView)(VkDevice device, VkImageView view);
typedef VkResult (VKAPI *PFN_vkCreateColorAttachmentView)(VkDevice device, const VkColorAttachmentViewCreateInfo* pCreateInfo, VkColorAttachmentView* pView); typedef VkResult (VKAPI *PFN_vkCreateAttachmentView)(VkDevice device, const VkAttachmentViewCreateInfo* pCreateInfo, VkAttachmentView* pView);
typedef VkResult (VKAPI *PFN_vkDestroyColorAttachmentView)(VkDevice device, VkColorAttachmentView view); typedef VkResult (VKAPI *PFN_vkDestroyAttachmentView)(VkDevice device, VkAttachmentView view);
typedef VkResult (VKAPI *PFN_vkCreateDepthStencilView)(VkDevice device, const VkDepthStencilViewCreateInfo* pCreateInfo, VkDepthStencilView* pView);
typedef VkResult (VKAPI *PFN_vkDestroyDepthStencilView)(VkDevice device, VkDepthStencilView view);
typedef VkResult (VKAPI *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModule* pShaderModule); typedef VkResult (VKAPI *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModule* pShaderModule);
typedef VkResult (VKAPI *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule); typedef VkResult (VKAPI *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule);
typedef VkResult (VKAPI *PFN_vkCreateShader)(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader); typedef VkResult (VKAPI *PFN_vkCreateShader)(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader);
@ -2113,7 +2150,8 @@ typedef void (VKAPI *PFN_vkCmdResetQueryPool)(VkCmdBuffer cmdBuffer, VkQueryPool
typedef void (VKAPI *PFN_vkCmdWriteTimestamp)(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset); typedef void (VKAPI *PFN_vkCmdWriteTimestamp)(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset);
typedef void (VKAPI *PFN_vkCmdCopyQueryPoolResults)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags); typedef void (VKAPI *PFN_vkCmdCopyQueryPoolResults)(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize destStride, VkQueryResultFlags flags);
typedef void (VKAPI *PFN_vkCmdPushConstants)(VkCmdBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values); typedef void (VKAPI *PFN_vkCmdPushConstants)(VkCmdBuffer cmdBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t start, uint32_t length, const void* values);
typedef void (VKAPI *PFN_vkCmdBeginRenderPass)(VkCmdBuffer cmdBuffer, const VkRenderPassBegin* pRenderPassBegin); typedef void (VKAPI *PFN_vkCmdBeginRenderPass)(VkCmdBuffer cmdBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkRenderPassContents contents);
typedef void (VKAPI *PFN_vkCmdNextSubpass)(VkCmdBuffer cmdBuffer, VkRenderPassContents contents);
typedef void (VKAPI *PFN_vkCmdEndRenderPass)(VkCmdBuffer cmdBuffer); typedef void (VKAPI *PFN_vkCmdEndRenderPass)(VkCmdBuffer cmdBuffer);
typedef void (VKAPI *PFN_vkCmdExecuteCommands)(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers); typedef void (VKAPI *PFN_vkCmdExecuteCommands)(VkCmdBuffer cmdBuffer, uint32_t cmdBuffersCount, const VkCmdBuffer* pCmdBuffers);
@ -2404,23 +2442,14 @@ VkResult VKAPI vkDestroyImageView(
VkDevice device, VkDevice device,
VkImageView imageView); VkImageView imageView);
VkResult VKAPI vkCreateColorAttachmentView( VkResult VKAPI vkCreateAttachmentView(
VkDevice device, VkDevice device,
const VkColorAttachmentViewCreateInfo* pCreateInfo, const VkAttachmentViewCreateInfo* pCreateInfo,
VkColorAttachmentView* pView); VkAttachmentView* pView);
VkResult VKAPI vkDestroyColorAttachmentView( VkResult VKAPI vkDestroyAttachmentView(
VkDevice device, VkDevice device,
VkColorAttachmentView view); VkAttachmentView view);
VkResult VKAPI vkCreateDepthStencilView(
VkDevice device,
const VkDepthStencilViewCreateInfo* pCreateInfo,
VkDepthStencilView* pView);
VkResult VKAPI vkDestroyDepthStencilView(
VkDevice device,
VkDepthStencilView view);
VkResult VKAPI vkCreateShaderModule( VkResult VKAPI vkCreateShaderModule(
VkDevice device, VkDevice device,
@ -2859,7 +2888,12 @@ void VKAPI vkCmdPushConstants(
void VKAPI vkCmdBeginRenderPass( void VKAPI vkCmdBeginRenderPass(
VkCmdBuffer cmdBuffer, VkCmdBuffer cmdBuffer,
const VkRenderPassBegin* pRenderPassBegin); const VkRenderPassBeginInfo* pRenderPassBegin,
VkRenderPassContents contents);
void VKAPI vkCmdNextSubpass(
VkCmdBuffer cmdBuffer,
VkRenderPassContents contents);
void VKAPI vkCmdEndRenderPass( void VKAPI vkCmdEndRenderPass(
VkCmdBuffer cmdBuffer); VkCmdBuffer cmdBuffer);

View File

@ -1216,11 +1216,8 @@ VkResult anv_DestroyObject(
case VK_OBJECT_TYPE_IMAGE_VIEW: case VK_OBJECT_TYPE_IMAGE_VIEW:
return anv_DestroyImageView(_device, _object); return anv_DestroyImageView(_device, _object);
case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW: case VK_OBJECT_TYPE_ATTACHMENT_VIEW:
return anv_DestroyColorAttachmentView(_device, _object); return anv_DestroyAttachmentView(_device, _object);
case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW:
return anv_DestroyDepthStencilView(_device, _object);
case VK_OBJECT_TYPE_IMAGE: case VK_OBJECT_TYPE_IMAGE:
return anv_DestroyImage(_device, _object); return anv_DestroyImage(_device, _object);
@ -1722,8 +1719,10 @@ VkResult anv_DestroyBufferView(
VkBufferView _view) VkBufferView _view)
{ {
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_surface_view *view = (struct anv_surface_view *)_view;
anv_surface_view_destroy(device, (struct anv_surface_view *)_view); anv_surface_view_fini(device, view);
anv_device_free(device, view);
return VK_SUCCESS; return VK_SUCCESS;
} }
@ -1882,6 +1881,7 @@ VkResult anv_CreateDescriptorSetLayout(
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for_each_bit(s, pCreateInfo->pBinding[i].stageFlags) for_each_bit(s, pCreateInfo->pBinding[i].stageFlags)
surface_count[s] += pCreateInfo->pBinding[i].arraySize; surface_count[s] += pCreateInfo->pBinding[i].arraySize;
break; break;
@ -1970,6 +1970,7 @@ VkResult anv_CreateDescriptorSetLayout(
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
for_each_bit(s, pCreateInfo->pBinding[i].stageFlags) for_each_bit(s, pCreateInfo->pBinding[i].stageFlags)
for (uint32_t j = 0; j < pCreateInfo->pBinding[i].arraySize; j++) { for (uint32_t j = 0; j < pCreateInfo->pBinding[i].arraySize; j++) {
surface[s]->index = descriptor + j; surface[s]->index = descriptor + j;
@ -2107,6 +2108,10 @@ VkResult anv_UpdateDescriptorSets(
anv_finishme("texel buffers not implemented"); anv_finishme("texel buffers not implemented");
break; break;
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
anv_finishme("input attachments not implemented");
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
@ -3049,8 +3054,10 @@ static VkResult
cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
unsigned stage, struct anv_state *bt_state) unsigned stage, struct anv_state *bt_state)
{ {
struct anv_framebuffer *fb = cmd_buffer->framebuffer;
struct anv_subpass *subpass = cmd_buffer->subpass;
struct anv_pipeline_layout *layout; struct anv_pipeline_layout *layout;
uint32_t color_attachments, bias, size; uint32_t attachments, bias, size;
if (stage == VK_SHADER_STAGE_COMPUTE) if (stage == VK_SHADER_STAGE_COMPUTE)
layout = cmd_buffer->compute_pipeline->layout; layout = cmd_buffer->compute_pipeline->layout;
@ -3059,10 +3066,10 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (stage == VK_SHADER_STAGE_FRAGMENT) { if (stage == VK_SHADER_STAGE_FRAGMENT) {
bias = MAX_RTS; bias = MAX_RTS;
color_attachments = cmd_buffer->framebuffer->color_attachment_count; attachments = subpass->color_count;
} else { } else {
bias = 0; bias = 0;
color_attachments = 0; attachments = 0;
} }
/* This is a little awkward: layout can be NULL but we still have to /* This is a little awkward: layout can be NULL but we still have to
@ -3070,7 +3077,7 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
* targets. */ * targets. */
uint32_t surface_count = layout ? layout->stage[stage].surface_count : 0; uint32_t surface_count = layout ? layout->stage[stage].surface_count : 0;
if (color_attachments + surface_count == 0) if (attachments + surface_count == 0)
return VK_SUCCESS; return VK_SUCCESS;
size = (bias + surface_count) * sizeof(uint32_t); size = (bias + surface_count) * sizeof(uint32_t);
@ -3080,9 +3087,19 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (bt_state->map == NULL) if (bt_state->map == NULL)
return VK_ERROR_OUT_OF_DEVICE_MEMORY; return VK_ERROR_OUT_OF_DEVICE_MEMORY;
for (uint32_t ca = 0; ca < color_attachments; ca++) { /* This is highly annoying. The Vulkan spec puts the depth-stencil
const struct anv_surface_view *view = * attachments in with the color attachments. Unfortunately, thanks to
cmd_buffer->framebuffer->color_attachments[ca]; * other aspects of the API, we cana't really saparate them before this
* point. Therefore, we have to walk all of the attachments but only
* put the color attachments into the binding table.
*/
for (uint32_t a = 0; a < attachments; a++) {
const struct anv_attachment_view *attachment =
fb->attachments[subpass->color_attachments[a]];
assert(attachment->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR);
const struct anv_color_attachment_view *view =
(const struct anv_color_attachment_view *)attachment;
struct anv_state state = struct anv_state state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer, 64, 64); anv_cmd_buffer_alloc_surface_state(cmd_buffer, 64, 64);
@ -3090,16 +3107,16 @@ cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (state.map == NULL) if (state.map == NULL)
return VK_ERROR_OUT_OF_DEVICE_MEMORY; return VK_ERROR_OUT_OF_DEVICE_MEMORY;
memcpy(state.map, view->surface_state.map, 64); memcpy(state.map, view->view.surface_state.map, 64);
/* The address goes in dwords 8 and 9 of the SURFACE_STATE */ /* The address goes in dwords 8 and 9 of the SURFACE_STATE */
*(uint64_t *)(state.map + 8 * 4) = *(uint64_t *)(state.map + 8 * 4) =
anv_reloc_list_add(&cmd_buffer->surface_relocs, anv_reloc_list_add(&cmd_buffer->surface_relocs,
cmd_buffer->device, cmd_buffer->device,
state.offset + 8 * 4, state.offset + 8 * 4,
view->bo, view->offset); view->view.bo, view->view.offset);
bt_map[ca] = state.offset; bt_map[a] = state.offset;
} }
if (layout == NULL) if (layout == NULL)
@ -3844,32 +3861,25 @@ VkResult anv_CreateFramebuffer(
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_framebuffer *framebuffer; struct anv_framebuffer *framebuffer;
static const struct anv_depth_stencil_view null_view =
{ .depth_format = D16_UNORM, .depth_stride = 0, .stencil_stride = 0 };
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
framebuffer = anv_device_alloc(device, sizeof(*framebuffer), 8, size_t size = sizeof(*framebuffer) +
sizeof(struct anv_attachment_view *) * pCreateInfo->attachmentCount;
framebuffer = anv_device_alloc(device, size, 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT); VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (framebuffer == NULL) if (framebuffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
framebuffer->base.destructor = anv_framebuffer_destroy; framebuffer->base.destructor = anv_framebuffer_destroy;
framebuffer->color_attachment_count = pCreateInfo->colorAttachmentCount; framebuffer->attachment_count = pCreateInfo->attachmentCount;
for (uint32_t i = 0; i < pCreateInfo->colorAttachmentCount; i++) { for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
framebuffer->color_attachments[i] = ANV_FROM_HANDLE(anv_attachment_view, view,
(struct anv_surface_view *) pCreateInfo->pColorAttachments[i].view; pCreateInfo->pAttachments[i].view);
framebuffer->attachments[i] = view;
} }
if (pCreateInfo->pDepthStencilAttachment) {
framebuffer->depth_stencil =
anv_depth_stencil_view_from_handle(pCreateInfo->pDepthStencilAttachment->view);
} else {
framebuffer->depth_stencil = &null_view;
}
framebuffer->sample_count = pCreateInfo->sampleCount;
framebuffer->width = pCreateInfo->width; framebuffer->width = pCreateInfo->width;
framebuffer->height = pCreateInfo->height; framebuffer->height = pCreateInfo->height;
framebuffer->layers = pCreateInfo->layers; framebuffer->layers = pCreateInfo->layers;
@ -3926,22 +3936,52 @@ VkResult anv_CreateRenderPass(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO); assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
size = sizeof(*pass) + size = sizeof(*pass) +
pCreateInfo->layers * sizeof(struct anv_render_pass_layer); pCreateInfo->subpassCount * sizeof(struct anv_subpass);
pass = anv_device_alloc(device, size, 8, pass = anv_device_alloc(device, size, 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT); VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (pass == NULL) if (pass == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
pass->render_area = pCreateInfo->renderArea; pass->attachment_count = pCreateInfo->attachmentCount;
size = pCreateInfo->attachmentCount * sizeof(*pass->attachments);
pass->attachments = anv_device_alloc(device, size, 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
pass->attachments[i].format = pCreateInfo->pAttachments[i].format;
pass->attachments[i].samples = pCreateInfo->pAttachments[i].samples;
pass->attachments[i].load_op = pCreateInfo->pAttachments[i].loadOp;
pass->attachments[i].stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
// pass->attachments[i].store_op = pCreateInfo->pAttachments[i].storeOp;
// pass->attachments[i].stencil_store_op = pCreateInfo->pAttachments[i].stencilStoreOp;
}
pass->num_layers = pCreateInfo->layers; for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
struct anv_subpass *subpass = &pass->subpasses[i];
pass->num_clear_layers = 0; subpass->input_count = desc->inputCount;
for (uint32_t i = 0; i < pCreateInfo->layers; i++) { subpass->input_attachments =
pass->layers[i].color_load_op = pCreateInfo->pColorLoadOps[i]; anv_device_alloc(device, desc->inputCount * sizeof(uint32_t),
pass->layers[i].clear_color = pCreateInfo->pColorLoadClearValues[i]; 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (pass->layers[i].color_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) for (uint32_t j = 0; j < desc->inputCount; j++)
pass->num_clear_layers++; subpass->input_attachments[j] = desc->inputAttachments[j].attachment;
subpass->color_count = desc->colorCount;
subpass->color_attachments =
anv_device_alloc(device, desc->colorCount * sizeof(uint32_t),
8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
for (uint32_t j = 0; j < desc->colorCount; j++)
subpass->color_attachments[j] = desc->colorAttachments[j].attachment;
if (desc->resolveAttachments) {
subpass->resolve_attachments =
anv_device_alloc(device, desc->colorCount * sizeof(uint32_t),
8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
for (uint32_t j = 0; j < desc->colorCount; j++)
subpass->resolve_attachments[j] = desc->resolveAttachments[j].attachment;
}
subpass->depth_stencil_attachment = desc->depthStencilAttachment.attachment;
} }
*pRenderPass = anv_render_pass_to_handle(pass); *pRenderPass = anv_render_pass_to_handle(pass);
@ -3956,6 +3996,14 @@ VkResult anv_DestroyRenderPass(
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_render_pass, pass, _pass); ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
anv_device_free(device, pass->attachments);
for (uint32_t i = 0; i < pass->attachment_count; i++) {
anv_device_free(device, pass->subpasses[i].input_attachments);
anv_device_free(device, pass->subpasses[i].color_attachments);
anv_device_free(device, pass->subpasses[i].resolve_attachments);
}
anv_device_free(device, pass); anv_device_free(device, pass);
return VK_SUCCESS; return VK_SUCCESS;
@ -3972,11 +4020,23 @@ VkResult anv_GetRenderAreaGranularity(
} }
static void static void
anv_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer, anv_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)
struct anv_render_pass *pass)
{ {
const struct anv_depth_stencil_view *view = struct anv_subpass *subpass = cmd_buffer->subpass;
cmd_buffer->framebuffer->depth_stencil; struct anv_framebuffer *fb = cmd_buffer->framebuffer;
const struct anv_depth_stencil_view *view;
static const struct anv_depth_stencil_view null_view =
{ .depth_format = D16_UNORM, .depth_stride = 0, .stencil_stride = 0 };
if (subpass->depth_stencil_attachment != VK_ATTACHMENT_UNUSED) {
const struct anv_attachment_view *aview =
fb->attachments[subpass->depth_stencil_attachment];
assert(aview->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL);
view = (const struct anv_depth_stencil_view *)aview;
} else {
view = &null_view;
}
/* FIXME: Implement the PMA stall W/A */ /* FIXME: Implement the PMA stall W/A */
/* FIXME: Width and Height are wrong */ /* FIXME: Width and Height are wrong */
@ -3989,8 +4049,8 @@ anv_cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer,
.SurfaceFormat = view->depth_format, .SurfaceFormat = view->depth_format,
.SurfacePitch = view->depth_stride > 0 ? view->depth_stride - 1 : 0, .SurfacePitch = view->depth_stride > 0 ? view->depth_stride - 1 : 0,
.SurfaceBaseAddress = { view->bo, view->depth_offset }, .SurfaceBaseAddress = { view->bo, view->depth_offset },
.Height = pass->render_area.extent.height - 1, .Height = cmd_buffer->framebuffer->height - 1,
.Width = pass->render_area.extent.width - 1, .Width = cmd_buffer->framebuffer->width - 1,
.LOD = 0, .LOD = 0,
.Depth = 1 - 1, .Depth = 1 - 1,
.MinimumArrayElement = 0, .MinimumArrayElement = 0,
@ -4023,33 +4083,59 @@ void anv_CmdPushConstants(
stub(); stub();
} }
void
anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
struct anv_subpass *subpass)
{
cmd_buffer->subpass = subpass;
cmd_buffer->descriptors_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT;
anv_cmd_buffer_emit_depth_stencil(cmd_buffer);
}
void anv_CmdBeginRenderPass( void anv_CmdBeginRenderPass(
VkCmdBuffer cmdBuffer, VkCmdBuffer cmdBuffer,
const VkRenderPassBegin* pRenderPassBegin) const VkRenderPassBeginInfo* pRenderPassBegin,
VkRenderPassContents contents)
{ {
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer); ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
ANV_FROM_HANDLE(anv_render_pass, pass, pRenderPassBegin->renderPass); ANV_FROM_HANDLE(anv_render_pass, pass, pRenderPassBegin->renderPass);
ANV_FROM_HANDLE(anv_framebuffer, framebuffer, pRenderPassBegin->framebuffer); ANV_FROM_HANDLE(anv_framebuffer, framebuffer, pRenderPassBegin->framebuffer);
assert(pRenderPassBegin->contents == VK_RENDER_PASS_CONTENTS_INLINE); assert(contents == VK_RENDER_PASS_CONTENTS_INLINE);
cmd_buffer->framebuffer = framebuffer; cmd_buffer->framebuffer = framebuffer;
cmd_buffer->pass = pass;
cmd_buffer->descriptors_dirty |= VK_SHADER_STAGE_FRAGMENT_BIT; const VkRect2D *render_area = &pRenderPassBegin->renderArea;
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_DRAWING_RECTANGLE, anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_DRAWING_RECTANGLE,
.ClippedDrawingRectangleYMin = pass->render_area.offset.y, .ClippedDrawingRectangleYMin = render_area->offset.y,
.ClippedDrawingRectangleXMin = pass->render_area.offset.x, .ClippedDrawingRectangleXMin = render_area->offset.x,
.ClippedDrawingRectangleYMax = .ClippedDrawingRectangleYMax =
pass->render_area.offset.y + pass->render_area.extent.height - 1, render_area->offset.y + render_area->extent.height - 1,
.ClippedDrawingRectangleXMax = .ClippedDrawingRectangleXMax =
pass->render_area.offset.x + pass->render_area.extent.width - 1, render_area->offset.x + render_area->extent.width - 1,
.DrawingRectangleOriginY = 0, .DrawingRectangleOriginY = 0,
.DrawingRectangleOriginX = 0); .DrawingRectangleOriginX = 0);
anv_cmd_buffer_emit_depth_stencil(cmd_buffer, pass); anv_cmd_buffer_clear_attachments(cmd_buffer, pass,
pRenderPassBegin->pAttachmentClearValues);
anv_cmd_buffer_clear(cmd_buffer, pass); anv_cmd_buffer_begin_subpass(cmd_buffer, pass->subpasses);
}
void anv_CmdNextSubpass(
VkCmdBuffer cmdBuffer,
VkRenderPassContents contents)
{
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
assert(contents == VK_RENDER_PASS_CONTENTS_INLINE);
cmd_buffer->subpass++;
anv_cmd_buffer_begin_subpass(cmd_buffer, cmd_buffer->subpass + 1);
} }
void anv_CmdEndRenderPass( void anv_CmdEndRenderPass(

View File

@ -215,6 +215,19 @@ anv_format_for_vk_format(VkFormat format)
return &anv_formats[format]; return &anv_formats[format];
} }
bool
anv_is_vk_format_depth_or_stencil(VkFormat format)
{
const struct anv_format *format_info =
anv_format_for_vk_format(format);
if (format_info->depth_format != UNSUPPORTED &&
format_info->depth_format != 0)
return true;
return format_info->has_stencil;
}
// Format capabilities // Format capabilities
struct surface_format_info { struct surface_format_info {

View File

@ -326,12 +326,10 @@ VkResult anv_GetImageSubresourceLayout(
} }
void void
anv_surface_view_destroy(struct anv_device *device, anv_surface_view_fini(struct anv_device *device,
struct anv_surface_view *view) struct anv_surface_view *view)
{ {
anv_state_pool_free(&device->surface_state_pool, view->surface_state); anv_state_pool_free(&device->surface_state_pool, view->surface_state);
anv_device_free(device, view);
} }
void void
@ -557,30 +555,32 @@ VkResult
anv_DestroyImageView(VkDevice _device, VkImageView _view) anv_DestroyImageView(VkDevice _device, VkImageView _view)
{ {
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_surface_view *view = (struct anv_surface_view *)_view;
anv_surface_view_destroy(device, (struct anv_surface_view *)_view); anv_surface_view_fini(device, view);
anv_device_free(device, view);
return VK_SUCCESS; return VK_SUCCESS;
} }
void void
anv_color_attachment_view_init(struct anv_surface_view *view, anv_color_attachment_view_init(struct anv_color_attachment_view *aview,
struct anv_device *device, struct anv_device *device,
const VkColorAttachmentViewCreateInfo* pCreateInfo, const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer) struct anv_cmd_buffer *cmd_buffer)
{ {
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_surface_view *view = &aview->view;
struct anv_surface *surface = &image->primary_surface; struct anv_surface *surface = &image->primary_surface;
const struct anv_format *format_info = const struct anv_format *format_info =
anv_format_for_vk_format(pCreateInfo->format); anv_format_for_vk_format(pCreateInfo->format);
aview->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_COLOR;
anv_assert(pCreateInfo->arraySize > 0); anv_assert(pCreateInfo->arraySize > 0);
anv_assert(pCreateInfo->mipLevel < image->levels); anv_assert(pCreateInfo->mipLevel < image->levels);
anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size);
if (pCreateInfo->msaaResolveImage)
anv_finishme("msaaResolveImage");
view->bo = image->bo; view->bo = image->bo;
view->offset = image->offset + surface->offset; view->offset = image->offset + surface->offset;
view->format = pCreateInfo->format; view->format = pCreateInfo->format;
@ -659,57 +659,17 @@ anv_color_attachment_view_init(struct anv_surface_view *view,
GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state); GEN8_RENDER_SURFACE_STATE_pack(NULL, view->surface_state.map, &surface_state);
} }
VkResult static void
anv_CreateColorAttachmentView(VkDevice _device, anv_depth_stencil_view_init(struct anv_depth_stencil_view *view,
const VkColorAttachmentViewCreateInfo *pCreateInfo, const VkAttachmentViewCreateInfo *pCreateInfo)
VkColorAttachmentView *pView)
{ {
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_surface_view *view;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO);
view = anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (view == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_color_attachment_view_init(view, device, pCreateInfo, NULL);
*pView = (VkColorAttachmentView) view;
return VK_SUCCESS;
}
VkResult
anv_DestroyColorAttachmentView(VkDevice _device, VkColorAttachmentView _view)
{
ANV_FROM_HANDLE(anv_device, device, _device);
anv_surface_view_destroy(device, (struct anv_surface_view *)_view);
return VK_SUCCESS;
}
VkResult
anv_CreateDepthStencilView(VkDevice _device,
const VkDepthStencilViewCreateInfo *pCreateInfo,
VkDepthStencilView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
struct anv_depth_stencil_view *view;
struct anv_surface *depth_surface = &image->primary_surface; struct anv_surface *depth_surface = &image->primary_surface;
struct anv_surface *stencil_surface = &image->stencil_surface; struct anv_surface *stencil_surface = &image->stencil_surface;
const struct anv_format *format = const struct anv_format *format =
anv_format_for_vk_format(image->format); anv_format_for_vk_format(image->format);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO); view->base.attachment_type = ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL;
view = anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (view == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
/* XXX: We don't handle any of these */ /* XXX: We don't handle any of these */
anv_assert(pCreateInfo->mipLevel == 0); anv_assert(pCreateInfo->mipLevel == 0);
@ -726,17 +686,54 @@ anv_CreateDepthStencilView(VkDevice _device,
view->stencil_stride = stencil_surface->stride; view->stencil_stride = stencil_surface->stride;
view->stencil_offset = image->offset + stencil_surface->offset; view->stencil_offset = image->offset + stencil_surface->offset;
view->stencil_qpitch = 0; /* FINISHME: QPitch */ view->stencil_qpitch = 0; /* FINISHME: QPitch */
}
*pView = anv_depth_stencil_view_to_handle(view); VkResult
anv_CreateAttachmentView(VkDevice _device,
const VkAttachmentViewCreateInfo *pCreateInfo,
VkAttachmentView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO);
if (anv_is_vk_format_depth_or_stencil(pCreateInfo->format)) {
struct anv_depth_stencil_view *view =
anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (view == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_depth_stencil_view_init(view, pCreateInfo);
*pView = anv_attachment_view_to_handle(&view->base);
} else {
struct anv_color_attachment_view *view =
anv_device_alloc(device, sizeof(*view), 8,
VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
if (view == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_color_attachment_view_init(view, device, pCreateInfo, NULL);
*pView = anv_attachment_view_to_handle(&view->base);
}
return VK_SUCCESS; return VK_SUCCESS;
} }
VkResult VkResult
anv_DestroyDepthStencilView(VkDevice _device, VkDepthStencilView _view) anv_DestroyAttachmentView(VkDevice _device, VkAttachmentView _view)
{ {
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_depth_stencil_view, view, _view); ANV_FROM_HANDLE(anv_attachment_view, view, _view);
if (view->attachment_type == ANV_ATTACHMENT_VIEW_TYPE_COLOR) {
struct anv_color_attachment_view *aview =
(struct anv_color_attachment_view *)view;
anv_surface_view_fini(device, &aview->view);
}
anv_device_free(device, view); anv_device_free(device, view);

View File

@ -263,32 +263,57 @@ meta_emit_clear(struct anv_cmd_buffer *cmd_buffer,
} }
void void
anv_cmd_buffer_clear(struct anv_cmd_buffer *cmd_buffer, anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
struct anv_render_pass *pass) struct anv_render_pass *pass,
const VkClearValue *clear_values)
{ {
struct anv_saved_state saved_state; struct anv_saved_state saved_state;
int num_clear_layers = 0; int num_clear_layers = 0;
struct clear_instance_data instance_data[MAX_RTS]; for (uint32_t i = 0; i < pass->attachment_count; i++) {
if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
for (uint32_t i = 0; i < pass->num_layers; i++) { if (anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
if (pass->layers[i].color_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) { anv_finishme("Can't clear depth-stencil yet");
instance_data[num_clear_layers++] = (struct clear_instance_data) { continue;
.vue_header = { }
.RTAIndex = i, num_clear_layers++;
.ViewportIndex = 0,
.PointWidth = 0.0
},
.color = pass->layers[i].clear_color,
};
} }
} }
if (num_clear_layers == 0) if (num_clear_layers == 0)
return; return;
struct clear_instance_data instance_data[num_clear_layers];
uint32_t color_attachments[num_clear_layers];
int layer = 0;
for (uint32_t i = 0; i < pass->attachment_count; i++) {
if (pass->attachments[i].load_op == VK_ATTACHMENT_LOAD_OP_CLEAR &&
!anv_is_vk_format_depth_or_stencil(pass->attachments[i].format)) {
instance_data[layer] = (struct clear_instance_data) {
.vue_header = {
.RTAIndex = i,
.ViewportIndex = 0,
.PointWidth = 0.0
},
.color = clear_values[i].color,
};
color_attachments[layer] = i;
layer++;
}
}
anv_cmd_buffer_save(cmd_buffer, &saved_state); anv_cmd_buffer_save(cmd_buffer, &saved_state);
struct anv_subpass subpass = {
.input_count = 0,
.color_count = num_clear_layers,
.color_attachments = color_attachments,
.depth_stencil_attachment = VK_ATTACHMENT_UNUSED,
};
anv_cmd_buffer_begin_subpass(cmd_buffer, &subpass);
meta_emit_clear(cmd_buffer, num_clear_layers, instance_data); meta_emit_clear(cmd_buffer, num_clear_layers, instance_data);
/* Restore API state */ /* Restore API state */
@ -500,7 +525,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
struct anv_surface_view *src, struct anv_surface_view *src,
VkOffset3D src_offset, VkOffset3D src_offset,
VkExtent3D src_extent, VkExtent3D src_extent,
struct anv_surface_view *dest, struct anv_color_attachment_view *dest,
VkOffset3D dest_offset, VkOffset3D dest_offset,
VkExtent3D dest_extent) VkExtent3D dest_extent)
{ {
@ -596,45 +621,67 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer,
anv_CreateFramebuffer(anv_device_to_handle(device), anv_CreateFramebuffer(anv_device_to_handle(device),
&(VkFramebufferCreateInfo) { &(VkFramebufferCreateInfo) {
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
.colorAttachmentCount = 1, .attachmentCount = 1,
.pColorAttachments = (VkColorAttachmentBindInfo[]) { .pAttachments = (VkAttachmentBindInfo[]) {
{ {
.view = (VkColorAttachmentView) dest, .view = anv_attachment_view_to_handle(&dest->base),
.layout = VK_IMAGE_LAYOUT_GENERAL .layout = VK_IMAGE_LAYOUT_GENERAL
} }
}, },
.pDepthStencilAttachment = NULL, .width = dest->view.extent.width,
.sampleCount = 1, .height = dest->view.extent.height,
.width = dest->extent.width,
.height = dest->extent.height,
.layers = 1 .layers = 1
}, &fb); }, &fb);
VkRenderPass pass; VkRenderPass pass;
anv_CreateRenderPass(anv_device_to_handle(device), anv_CreateRenderPass(anv_device_to_handle(device),
&(VkRenderPassCreateInfo) { &(VkRenderPassCreateInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.renderArea = { { 0, 0 }, { dest->extent.width, dest->extent.height } }, .attachmentCount = 1,
.colorAttachmentCount = 1, .pAttachments = &(VkAttachmentDescription) {
.extent = { 0, }, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
.sampleCount = 1, .format = dest->view.format,
.layers = 1, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.pColorFormats = (VkFormat[]) { dest->format }, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.pColorLayouts = (VkImageLayout[]) { VK_IMAGE_LAYOUT_GENERAL }, .initialLayout = VK_IMAGE_LAYOUT_GENERAL,
.pColorLoadOps = (VkAttachmentLoadOp[]) { VK_ATTACHMENT_LOAD_OP_LOAD }, .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
.pColorStoreOps = (VkAttachmentStoreOp[]) { VK_ATTACHMENT_STORE_OP_STORE },
.pColorLoadClearValues = (VkClearColorValue[]) {
{ .f32 = { 1.0, 0.0, 0.0, 1.0 } }
}, },
.depthStencilFormat = VK_FORMAT_UNDEFINED, .subpassCount = 1,
.pSubpasses = &(VkSubpassDescription) {
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputCount = 0,
.colorCount = 1,
.colorAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
.resolveAttachments = NULL,
.depthStencilAttachment = (VkAttachmentReference) {
.attachment = VK_ATTACHMENT_UNUSED,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
.preserveCount = 1,
.preserveAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
},
.dependencyCount = 0,
}, &pass); }, &pass);
anv_CmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer), anv_CmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer),
&(VkRenderPassBegin) { &(VkRenderPassBeginInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.renderPass = pass, .renderPass = pass,
.framebuffer = fb, .framebuffer = fb,
}); .renderArea = {
.offset = { dest_offset.x, dest_offset.y },
.extent = { dest_extent.width, dest_extent.height },
},
.attachmentCount = 1,
.pAttachmentClearValues = NULL,
}, VK_RENDER_PASS_CONTENTS_INLINE);
anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer), anv_CmdBindDynamicStateObject(anv_cmd_buffer_to_handle(cmd_buffer),
VK_STATE_BIND_POINT_VIEWPORT, VK_STATE_BIND_POINT_VIEWPORT,
@ -747,10 +794,10 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
}, },
cmd_buffer); cmd_buffer);
struct anv_surface_view dest_view; struct anv_color_attachment_view dest_view;
anv_color_attachment_view_init(&dest_view, cmd_buffer->device, anv_color_attachment_view_init(&dest_view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = dest_image, .image = dest_image,
.format = copy_format, .format = copy_format,
.mipLevel = 0, .mipLevel = 0,
@ -887,10 +934,10 @@ void anv_CmdCopyImage(
}, },
cmd_buffer); cmd_buffer);
struct anv_surface_view dest_view; struct anv_color_attachment_view dest_view;
anv_color_attachment_view_init(&dest_view, cmd_buffer->device, anv_color_attachment_view_init(&dest_view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage, .image = destImage,
.format = src_image->format, .format = src_image->format,
.mipLevel = pRegions[r].destSubresource.mipLevel, .mipLevel = pRegions[r].destSubresource.mipLevel,
@ -955,10 +1002,10 @@ void anv_CmdBlitImage(
}, },
cmd_buffer); cmd_buffer);
struct anv_surface_view dest_view; struct anv_color_attachment_view dest_view;
anv_color_attachment_view_init(&dest_view, cmd_buffer->device, anv_color_attachment_view_init(&dest_view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage, .image = destImage,
.format = dest_image->format, .format = dest_image->format,
.mipLevel = pRegions[r].destSubresource.mipLevel, .mipLevel = pRegions[r].destSubresource.mipLevel,
@ -1051,10 +1098,10 @@ void anv_CmdCopyBufferToImage(
}, },
cmd_buffer); cmd_buffer);
struct anv_surface_view dest_view; struct anv_color_attachment_view dest_view;
anv_color_attachment_view_init(&dest_view, cmd_buffer->device, anv_color_attachment_view_init(&dest_view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = anv_image_to_handle(dest_image), .image = anv_image_to_handle(dest_image),
.format = dest_image->format, .format = dest_image->format,
.mipLevel = pRegions[r].imageSubresource.mipLevel, .mipLevel = pRegions[r].imageSubresource.mipLevel,
@ -1149,10 +1196,10 @@ void anv_CmdCopyImageToBuffer(
dest_image->bo = dest_buffer->bo; dest_image->bo = dest_buffer->bo;
dest_image->offset = dest_buffer->offset + pRegions[r].bufferOffset; dest_image->offset = dest_buffer->offset + pRegions[r].bufferOffset;
struct anv_surface_view dest_view; struct anv_color_attachment_view dest_view;
anv_color_attachment_view_init(&dest_view, cmd_buffer->device, anv_color_attachment_view_init(&dest_view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = destImage, .image = destImage,
.format = src_image->format, .format = src_image->format,
.mipLevel = 0, .mipLevel = 0,
@ -1212,10 +1259,10 @@ void anv_CmdClearColorImage(
for (uint32_t r = 0; r < rangeCount; r++) { for (uint32_t r = 0; r < rangeCount; r++) {
for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) { for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) {
for (uint32_t s = 0; s < pRanges[r].arraySize; s++) { for (uint32_t s = 0; s < pRanges[r].arraySize; s++) {
struct anv_surface_view view; struct anv_color_attachment_view view;
anv_color_attachment_view_init(&view, cmd_buffer->device, anv_color_attachment_view_init(&view, cmd_buffer->device,
&(VkColorAttachmentViewCreateInfo) { &(VkAttachmentViewCreateInfo) {
.sType = VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
.image = _image, .image = _image,
.format = image->format, .format = image->format,
.mipLevel = pRanges[r].baseMipLevel + l, .mipLevel = pRanges[r].baseMipLevel + l,
@ -1228,17 +1275,15 @@ void anv_CmdClearColorImage(
anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device), anv_CreateFramebuffer(anv_device_to_handle(cmd_buffer->device),
&(VkFramebufferCreateInfo) { &(VkFramebufferCreateInfo) {
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
.colorAttachmentCount = 1, .attachmentCount = 1,
.pColorAttachments = (VkColorAttachmentBindInfo[]) { .pAttachments = (VkAttachmentBindInfo[]) {
{ {
.view = (VkColorAttachmentView) &view, .view = anv_attachment_view_to_handle(&view.base),
.layout = VK_IMAGE_LAYOUT_GENERAL .layout = VK_IMAGE_LAYOUT_GENERAL
} }
}, },
.pDepthStencilAttachment = NULL, .width = view.view.extent.width,
.sampleCount = 1, .height = view.view.extent.height,
.width = view.extent.width,
.height = view.extent.height,
.layers = 1 .layers = 1
}, &fb); }, &fb);
@ -1246,24 +1291,54 @@ void anv_CmdClearColorImage(
anv_CreateRenderPass(anv_device_to_handle(cmd_buffer->device), anv_CreateRenderPass(anv_device_to_handle(cmd_buffer->device),
&(VkRenderPassCreateInfo) { &(VkRenderPassCreateInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.renderArea = { { 0, 0 }, { view.extent.width, view.extent.height } }, .attachmentCount = 1,
.colorAttachmentCount = 1, .pAttachments = &(VkAttachmentDescription) {
.extent = { 0, }, .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
.sampleCount = 1, .format = view.view.format,
.layers = 1, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.pColorFormats = (VkFormat[]) { image->format }, .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.pColorLayouts = (VkImageLayout[]) { imageLayout }, .initialLayout = VK_IMAGE_LAYOUT_GENERAL,
.pColorLoadOps = (VkAttachmentLoadOp[]) { VK_ATTACHMENT_LOAD_OP_DONT_CARE }, .finalLayout = VK_IMAGE_LAYOUT_GENERAL,
.pColorStoreOps = (VkAttachmentStoreOp[]) { VK_ATTACHMENT_STORE_OP_STORE }, },
.pColorLoadClearValues = pColor, .subpassCount = 1,
.depthStencilFormat = VK_FORMAT_UNDEFINED, .pSubpasses = &(VkSubpassDescription) {
.sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
.inputCount = 0,
.colorCount = 1,
.colorAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
.resolveAttachments = NULL,
.depthStencilAttachment = (VkAttachmentReference) {
.attachment = VK_ATTACHMENT_UNUSED,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
.preserveCount = 1,
.preserveAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
},
.dependencyCount = 0,
}, &pass); }, &pass);
anv_CmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer), anv_CmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer),
&(VkRenderPassBegin) { &(VkRenderPassBeginInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
.renderArea = {
.offset = { 0, 0, },
.extent = {
.width = view.view.extent.width,
.height = view.view.extent.height,
},
},
.renderPass = pass, .renderPass = pass,
.framebuffer = fb, .framebuffer = fb,
}); .attachmentCount = 1,
.pAttachmentClearValues = NULL,
}, VK_RENDER_PASS_CONTENTS_INLINE);
struct clear_instance_data instance_data = { struct clear_instance_data instance_data = {
.vue_header = { .vue_header = {

View File

@ -695,6 +695,8 @@ struct anv_cmd_buffer {
struct anv_pipeline * pipeline; struct anv_pipeline * pipeline;
struct anv_pipeline * compute_pipeline; struct anv_pipeline * compute_pipeline;
struct anv_framebuffer * framebuffer; struct anv_framebuffer * framebuffer;
struct anv_render_pass * pass;
struct anv_subpass * subpass;
struct anv_dynamic_rs_state * rs_state; struct anv_dynamic_rs_state * rs_state;
struct anv_dynamic_ds_state * ds_state; struct anv_dynamic_ds_state * ds_state;
struct anv_dynamic_vp_state * vp_state; struct anv_dynamic_vp_state * vp_state;
@ -797,12 +799,13 @@ struct anv_format {
uint16_t surface_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */ uint16_t surface_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */
uint8_t cpp; /**< Bytes-per-pixel of anv_format::surface_format. */ uint8_t cpp; /**< Bytes-per-pixel of anv_format::surface_format. */
uint8_t num_channels; uint8_t num_channels;
uint8_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */ uint16_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
bool has_stencil; bool has_stencil;
}; };
const struct anv_format * const struct anv_format *
anv_format_for_vk_format(VkFormat format); anv_format_for_vk_format(VkFormat format);
bool anv_is_vk_format_depth_or_stencil(VkFormat format);
/** /**
* A proxy for the color surfaces, depth surfaces, and stencil surfaces. * A proxy for the color surfaces, depth surfaces, and stencil surfaces.
@ -866,6 +869,36 @@ struct anv_surface_view {
VkFormat format; VkFormat format;
}; };
enum anv_attachment_view_type {
ANV_ATTACHMENT_VIEW_TYPE_COLOR,
ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL,
};
struct anv_attachment_view {
enum anv_attachment_view_type attachment_type;
};
struct anv_color_attachment_view {
struct anv_attachment_view base;
struct anv_surface_view view;
};
struct anv_depth_stencil_view {
struct anv_attachment_view base;
struct anv_bo *bo;
uint32_t depth_offset; /**< Offset into bo. */
uint32_t depth_stride; /**< 3DSTATE_DEPTH_BUFFER.SurfacePitch */
uint32_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
uint16_t depth_qpitch; /**< 3DSTATE_DEPTH_BUFFER.SurfaceQPitch */
uint32_t stencil_offset; /**< Offset into bo. */
uint32_t stencil_stride; /**< 3DSTATE_STENCIL_BUFFER.SurfacePitch */
uint16_t stencil_qpitch; /**< 3DSTATE_STENCIL_BUFFER.SurfaceQPitch */
};
struct anv_image_create_info { struct anv_image_create_info {
const VkImageCreateInfo *vk_info; const VkImageCreateInfo *vk_info;
bool force_tile_mode; bool force_tile_mode;
@ -881,65 +914,66 @@ void anv_image_view_init(struct anv_surface_view *view,
const VkImageViewCreateInfo* pCreateInfo, const VkImageViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer); struct anv_cmd_buffer *cmd_buffer);
void anv_color_attachment_view_init(struct anv_surface_view *view, void anv_color_attachment_view_init(struct anv_color_attachment_view *view,
struct anv_device *device, struct anv_device *device,
const VkColorAttachmentViewCreateInfo* pCreateInfo, const VkAttachmentViewCreateInfo* pCreateInfo,
struct anv_cmd_buffer *cmd_buffer); struct anv_cmd_buffer *cmd_buffer);
void anv_surface_view_destroy(struct anv_device *device, void anv_surface_view_fini(struct anv_device *device,
struct anv_surface_view *view); struct anv_surface_view *view);
struct anv_sampler { struct anv_sampler {
uint32_t state[4]; uint32_t state[4];
}; };
struct anv_depth_stencil_view {
struct anv_bo *bo;
uint32_t depth_offset; /**< Offset into bo. */
uint32_t depth_stride; /**< 3DSTATE_DEPTH_BUFFER.SurfacePitch */
uint32_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
uint16_t depth_qpitch; /**< 3DSTATE_DEPTH_BUFFER.SurfaceQPitch */
uint32_t stencil_offset; /**< Offset into bo. */
uint32_t stencil_stride; /**< 3DSTATE_STENCIL_BUFFER.SurfacePitch */
uint16_t stencil_qpitch; /**< 3DSTATE_STENCIL_BUFFER.SurfaceQPitch */
};
struct anv_framebuffer { struct anv_framebuffer {
struct anv_object base; struct anv_object base;
uint32_t color_attachment_count;
const struct anv_surface_view * color_attachments[MAX_RTS];
const struct anv_depth_stencil_view * depth_stencil;
uint32_t sample_count;
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
uint32_t layers; uint32_t layers;
/* Viewport for clears */ /* Viewport for clears */
VkDynamicViewportState vp_state; VkDynamicViewportState vp_state;
uint32_t attachment_count;
const struct anv_attachment_view * attachments[0];
}; };
struct anv_render_pass_layer { struct anv_subpass {
VkAttachmentLoadOp color_load_op; uint32_t input_count;
VkClearColorValue clear_color; uint32_t * input_attachments;
uint32_t color_count;
uint32_t * color_attachments;
uint32_t * resolve_attachments;
uint32_t depth_stencil_attachment;
};
struct anv_render_pass_attachment {
VkFormat format;
uint32_t samples;
VkAttachmentLoadOp load_op;
VkAttachmentLoadOp stencil_load_op;
}; };
struct anv_render_pass { struct anv_render_pass {
VkRect2D render_area; uint32_t attachment_count;
struct anv_render_pass_attachment * attachments;
uint32_t num_clear_layers; struct anv_subpass subpasses[0];
uint32_t num_layers;
struct anv_render_pass_layer layers[0];
}; };
void anv_device_init_meta(struct anv_device *device); void anv_device_init_meta(struct anv_device *device);
void anv_device_finish_meta(struct anv_device *device); void anv_device_finish_meta(struct anv_device *device);
void void
anv_cmd_buffer_clear(struct anv_cmd_buffer *cmd_buffer, anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
struct anv_render_pass *pass); struct anv_subpass *subpass);
void
anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
struct anv_render_pass *pass,
const VkClearValue *clear_values);
void * void *
anv_lookup_entrypoint(const char *name); anv_lookup_entrypoint(const char *name);
@ -977,7 +1011,7 @@ ANV_DEFINE_CASTS(anv_shader, VkShader)
ANV_DEFINE_CASTS(anv_pipeline, VkPipeline) ANV_DEFINE_CASTS(anv_pipeline, VkPipeline)
ANV_DEFINE_CASTS(anv_image, VkImage) ANV_DEFINE_CASTS(anv_image, VkImage)
ANV_DEFINE_CASTS(anv_sampler, VkSampler) ANV_DEFINE_CASTS(anv_sampler, VkSampler)
ANV_DEFINE_CASTS(anv_depth_stencil_view, VkDepthStencilView) ANV_DEFINE_CASTS(anv_attachment_view, VkAttachmentView)
ANV_DEFINE_CASTS(anv_framebuffer, VkFramebuffer) ANV_DEFINE_CASTS(anv_framebuffer, VkFramebuffer)
ANV_DEFINE_CASTS(anv_render_pass, VkRenderPass) ANV_DEFINE_CASTS(anv_render_pass, VkRenderPass)
ANV_DEFINE_CASTS(anv_query_pool, VkQueryPool) ANV_DEFINE_CASTS(anv_query_pool, VkQueryPool)