Only slightly tested.
Conflicts:
include/vulkan.h
VkBuffer buf;
VkDeviceMemory mem;
VkBufferView view;
- VkBufferViewAttachInfo attach;
+ VkDescriptorInfo desc;
} uniform_data;
VkCmdBuffer cmd; // Buffer for initialization commands
err = vkCreateBufferView(demo->device, &view_info, &demo->uniform_data.view);
assert(!err);
- demo->uniform_data.attach.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO;
- demo->uniform_data.attach.view = demo->uniform_data.view;
+ demo->uniform_data.desc.bufferView = demo->uniform_data.view;
}
static void demo_prepare_descriptor_layout(struct demo *demo)
static void demo_prepare_descriptor_set(struct demo *demo)
{
- VkImageViewAttachInfo view_info[DEMO_TEXTURE_COUNT];
- VkSamplerImageViewInfo combined_info[DEMO_TEXTURE_COUNT];
- VkUpdateSamplerTextures update_fs;
- VkUpdateBuffers update_vs;
- const void *update_array[2] = { &update_vs, &update_fs };
+ VkDescriptorInfo tex_descs[DEMO_TEXTURE_COUNT];
+ VkWriteDescriptorSet writes[2];
VkResult U_ASSERT_ONLY err;
uint32_t count;
uint32_t i;
- for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
- view_info[i].sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO;
- view_info[i].pNext = NULL;
- view_info[i].view = demo->textures[i].view,
- view_info[i].layout = VK_IMAGE_LAYOUT_GENERAL;
-
- combined_info[i].sampler = demo->textures[i].sampler;
- combined_info[i].pImageView = &view_info[i];
- }
-
- memset(&update_vs, 0, sizeof(update_vs));
- update_vs.sType = VK_STRUCTURE_TYPE_UPDATE_BUFFERS;
- update_vs.pNext = &update_fs;
- update_vs.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
- update_vs.count = 1;
- update_vs.pBufferViews = &demo->uniform_data.attach;
-
- memset(&update_fs, 0, sizeof(update_fs));
- update_fs.sType = VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES;
- update_fs.binding = 1;
- update_fs.count = DEMO_TEXTURE_COUNT;
- update_fs.pSamplerImageViews = combined_info;
-
err = vkAllocDescriptorSets(demo->device, demo->desc_pool,
VK_DESCRIPTOR_SET_USAGE_STATIC,
1, &demo->desc_layout,
assert(!err && count == 1);
vkClearDescriptorSets(demo->device, demo->desc_pool, 1, &demo->desc_set);
- vkUpdateDescriptors(demo->device, demo->desc_set, 2, update_array);
+
+ memset(&tex_descs, 0, sizeof(tex_descs));
+ for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
+ tex_descs[i].sampler = demo->textures[i].sampler;
+ tex_descs[i].imageView = demo->textures[i].view;
+ tex_descs[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
+ }
+
+ memset(&writes, 0, sizeof(writes));
+
+ writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ writes[0].destSet = demo->desc_set;
+ writes[0].count = 1;
+ writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+ writes[0].pDescriptors = &demo->uniform_data.desc;
+
+ writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ writes[1].destSet = demo->desc_set;
+ writes[1].destBinding = 1;
+ writes[1].count = DEMO_TEXTURE_COUNT;
+ writes[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ writes[1].pDescriptors = tex_descs;
+
+ err = vkUpdateDescriptorSets(demo->device, 2, writes, 0, NULL);
+ assert(!err);
}
static void demo_prepare(struct demo *demo)
static void demo_prepare_descriptor_set(struct demo *demo)
{
- VkImageViewAttachInfo view_info[DEMO_TEXTURE_COUNT];
- VkSamplerImageViewInfo combined_info[DEMO_TEXTURE_COUNT];
- VkUpdateSamplerTextures update;
- const void *update_array[1] = { &update };
+ VkDescriptorInfo tex_descs[DEMO_TEXTURE_COUNT];
+ VkWriteDescriptorSet write;
VkResult U_ASSERT_ONLY err;
uint32_t count;
uint32_t i;
- for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
- view_info[i].sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO;
- view_info[i].pNext = NULL;
- view_info[i].view = demo->textures[i].view,
- view_info[i].layout = VK_IMAGE_LAYOUT_GENERAL;
-
- combined_info[i].sampler = demo->textures[i].sampler;
- combined_info[i].pImageView = &view_info[i];
- }
-
- memset(&update, 0, sizeof(update));
- update.sType = VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES;
- update.count = DEMO_TEXTURE_COUNT;
- update.pSamplerImageViews = combined_info;
-
err = vkAllocDescriptorSets(demo->device, demo->desc_pool,
VK_DESCRIPTOR_SET_USAGE_STATIC,
1, &demo->desc_layout,
assert(!err && count == 1);
vkClearDescriptorSets(demo->device, demo->desc_pool, 1, &demo->desc_set);
- vkUpdateDescriptors(demo->device, demo->desc_set, 1, update_array);
+
+ memset(&tex_descs, 0, sizeof(tex_descs));
+ for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
+ tex_descs[i].sampler = demo->textures[i].sampler;
+ tex_descs[i].imageView = demo->textures[i].view;
+ tex_descs[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
+ }
+
+ memset(&write, 0, sizeof(write));
+ write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ write.destSet = demo->desc_set;
+ write.count = DEMO_TEXTURE_COUNT;
+ write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ write.pDescriptors = tex_descs;
+
+ err = vkUpdateDescriptorSets(demo->device, 1, &write, 0, NULL);
+ assert(!err);
}
static void demo_prepare(struct demo *demo)
NULLDRV_LOG_FUNC;
}
-ICD_EXPORT void VKAPI vkUpdateDescriptors(
- VkDevice device,
- VkDescriptorSet descriptorSet,
- uint32_t updateCount,
- const void** ppUpdateArray)
+ICD_EXPORT VkResult VKAPI vkUpdateDescriptorSets(
+ VkDevice device,
+ uint32_t writeCount,
+ const VkWriteDescriptorSet* pDescriptorWrites,
+ uint32_t copyCount,
+ const VkCopyDescriptorSet* pDescriptorCopies)
{
NULLDRV_LOG_FUNC;
+ return VK_SUCCESS;
}
ICD_EXPORT VkResult VKAPI vkCreateFramebuffer(
PFN_vkResetDescriptorPool ResetDescriptorPool;
PFN_vkAllocDescriptorSets AllocDescriptorSets;
PFN_vkClearDescriptorSets ClearDescriptorSets;
- PFN_vkUpdateDescriptors UpdateDescriptors;
+ PFN_vkUpdateDescriptorSets UpdateDescriptorSets;
PFN_vkCreateDynamicViewportState CreateDynamicViewportState;
PFN_vkCreateDynamicRasterState CreateDynamicRasterState;
PFN_vkCreateDynamicColorBlendState CreateDynamicColorBlendState;
#include "vk_platform.h"
// Vulkan API version supported by this file
-#define VK_API_VERSION VK_MAKE_VERSION(0, 97, 2)
+#define VK_API_VERSION VK_MAKE_VERSION(0, 98, 0)
#ifdef __cplusplus
extern "C"
VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO = 2,
VK_STRUCTURE_TYPE_MEMORY_OPEN_INFO = 3,
VK_STRUCTURE_TYPE_PEER_MEMORY_OPEN_INFO = 4,
- VK_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO = 5,
- VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO = 6,
+// VK_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO = 5,
+// VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO = 6,
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 7,
VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO = 8,
VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO = 9,
VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 43,
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 44,
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 45,
- VK_STRUCTURE_TYPE_UPDATE_SAMPLERS = 46,
- VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES = 47,
- VK_STRUCTURE_TYPE_UPDATE_IMAGES = 48,
- VK_STRUCTURE_TYPE_UPDATE_BUFFERS = 49,
- VK_STRUCTURE_TYPE_UPDATE_AS_COPY = 50,
- VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 51,
- VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 52,
- VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 53,
+ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 46,
+ VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 47,
+ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 48,
+ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 49,
+ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 50,
VK_ENUM_RANGE(STRUCTURE_TYPE, APPLICATION_INFO, MAPPED_MEMORY_RANGE)
} VkStructureType;
VkFormatFeatureFlags optimalTilingFeatures; // Format features in case of optimal tiling
} VkFormatProperties;
-typedef struct VkBufferViewAttachInfo_
+typedef struct VkDescriptorInfo_
{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO
- const void* pNext; // Pointer to next structure
- VkBufferView view;
-} VkBufferViewAttachInfo;
+ VkBufferView bufferView; // Buffer view to write to the descriptor (in case it's a buffer descriptor, otherwise should be VK_NULL_HANDLE)
+ VkSampler sampler; // Sampler to write to the descriptor (in case it's a SAMPLER or COMBINED_IMAGE_SAMPLER descriptor, otherwise should be VK_NULL_HANDLE)
+ VkImageView imageView; // Image view to write to the descriptor (in case it's a SAMPLED_IMAGE, STORAGE_IMAGE, or COMBINED_IMAGE_SAMPLER descriptor, otherwise should be VK_NULL_HANDLE)
+ VkImageLayout imageLayout; // Layout the image is expected to be in when accessed using this descriptor (only used if <imageView> is not VK_NULL_HANDLE)
+} VkDescriptorInfo;
-typedef struct VkImageViewAttachInfo_
+typedef struct VkWriteDescriptorSet_
{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO
+ VkStructureType sType; // Must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
const void* pNext; // Pointer to next structure
- VkImageView view;
- VkImageLayout layout;
-} VkImageViewAttachInfo;
-typedef struct VkUpdateSamplers_
-{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_UPDATE_SAMPLERS
- const void* pNext; // Pointer to next structure
- uint32_t binding; // Binding of the sampler (array)
- uint32_t arrayIndex; // First element of the array to update or zero otherwise
- uint32_t count; // Number of elements to update
- const VkSampler* pSamplers;
-} VkUpdateSamplers;
+ VkDescriptorSet destSet; // Destination descriptor set
+ uint32_t destBinding; // Binding within the destination descriptor set to write
+ uint32_t destArrayElement; // Array element within the destination binding to write
-typedef struct VkSamplerImageViewInfo_
-{
- VkSampler sampler;
- const VkImageViewAttachInfo* pImageView;
-} VkSamplerImageViewInfo;
+ uint32_t count; // Number of descriptors to write (determines the size of the array pointed by <pDescriptors>)
+
+ VkDescriptorType descriptorType; // Descriptor type to write (determines which fields of the array pointed by <pDescriptors> are going to be used)
+ const VkDescriptorInfo* pDescriptors; // Array of info structures describing the descriptors to write
+} VkWriteDescriptorSet;
-typedef struct VkUpdateSamplerTextures_
+typedef struct VkCopyDescriptorSet_
{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES
+ VkStructureType sType; // Must be VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET
const void* pNext; // Pointer to next structure
- uint32_t binding; // Binding of the combined texture sampler (array)
- uint32_t arrayIndex; // First element of the array to update or zero otherwise
- uint32_t count; // Number of elements to update
- const VkSamplerImageViewInfo* pSamplerImageViews;
-} VkUpdateSamplerTextures;
-
-typedef struct VkUpdateImages_
-{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_UPDATE_IMAGES
- const void* pNext; // Pointer to next structure
- VkDescriptorType descriptorType;
- uint32_t binding; // Binding of the image (array)
- uint32_t arrayIndex; // First element of the array to update or zero otherwise
- uint32_t count; // Number of elements to update
- const VkImageViewAttachInfo* pImageViews;
-} VkUpdateImages;
-
-typedef struct VkUpdateBuffers_
-{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_UPDATE_BUFFERS
- const void* pNext; // Pointer to next structure
- VkDescriptorType descriptorType;
- uint32_t binding; // Binding of the buffer (array)
- uint32_t arrayIndex; // First element of the array to update or zero otherwise
- uint32_t count; // Number of elements to update
- const VkBufferViewAttachInfo* pBufferViews;
-} VkUpdateBuffers;
-
-typedef struct VkUpdateAsCopy_
-{
- VkStructureType sType; // Must be VK_STRUCTURE_TYPE_UPDATE_AS_COPY
- const void* pNext; // Pointer to next structure
- VkDescriptorType descriptorType;
- VkDescriptorSet descriptorSet;
- uint32_t binding;
- uint32_t arrayElement;
- uint32_t count;
-} VkUpdateAsCopy;
+
+ VkDescriptorSet srcSet; // Source descriptor set
+ uint32_t srcBinding; // Binding within the source descriptor set to copy from
+ uint32_t srcArrayElement; // Array element within the source binding to copy from
+
+ VkDescriptorSet destSet; // Destination descriptor set
+ uint32_t destBinding; // Binding within the destination descriptor set to copy to
+ uint32_t destArrayElement; // Array element within the destination binding to copy to
+
+ uint32_t count; // Number of descriptors to copy
+} VkCopyDescriptorSet;
typedef struct VkBufferCreateInfo_
{
typedef VkResult (VKAPI *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool);
typedef VkResult (VKAPI *PFN_vkAllocDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount);
typedef void (VKAPI *PFN_vkClearDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets);
-typedef void (VKAPI *PFN_vkUpdateDescriptors)(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray);
+typedef VkResult (VKAPI *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies);
typedef VkResult (VKAPI *PFN_vkCreateDynamicViewportState)(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState);
typedef VkResult (VKAPI *PFN_vkCreateDynamicRasterState)(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState);
typedef VkResult (VKAPI *PFN_vkCreateDynamicColorBlendState)(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState);
uint32_t count,
const VkDescriptorSet* pDescriptorSets);
-void VKAPI vkUpdateDescriptors(
+VkResult VKAPI vkUpdateDescriptorSets(
VkDevice device,
- VkDescriptorSet descriptorSet,
- uint32_t updateCount,
- const void** ppUpdateArray);
+ uint32_t writeCount,
+ const VkWriteDescriptorSet* pDescriptorWrites,
+ uint32_t copyCount,
+ const VkCopyDescriptorSet* pDescriptorCopies);
// State object functions
char str[1024];
switch (pUpdateStruct->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
return 1;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType);
char str[1024];
switch (pUpdateStruct->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- return ((VkUpdateSamplers*)pUpdateStruct)->binding;
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- return ((VkUpdateSamplerTextures*)pUpdateStruct)->binding;
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- return ((VkUpdateImages*)pUpdateStruct)->binding;
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- return ((VkUpdateBuffers*)pUpdateStruct)->binding;
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
- return ((VkUpdateAsCopy*)pUpdateStruct)->binding;
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ return ((VkWriteDescriptorSet*)pUpdateStruct)->destBinding;
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
+ return ((VkCopyDescriptorSet*)pUpdateStruct)->destBinding;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType);
layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str);
char str[1024];
switch (pUpdateStruct->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- return (((VkUpdateSamplers*)pUpdateStruct)->arrayIndex);
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- return (((VkUpdateSamplerTextures*)pUpdateStruct)->arrayIndex);
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- return (((VkUpdateImages*)pUpdateStruct)->arrayIndex);
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- return (((VkUpdateBuffers*)pUpdateStruct)->arrayIndex);
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ return ((VkWriteDescriptorSet*)pUpdateStruct)->destArrayElement;
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
// TODO : Need to understand this case better and make sure code is correct
- return (((VkUpdateAsCopy*)pUpdateStruct)->arrayElement);
+ return ((VkCopyDescriptorSet*)pUpdateStruct)->destArrayElement;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType);
layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str);
char str[1024];
switch (pUpdateStruct->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- return (((VkUpdateSamplers*)pUpdateStruct)->count);
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- return (((VkUpdateSamplerTextures*)pUpdateStruct)->count);
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- return (((VkUpdateImages*)pUpdateStruct)->count);
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- return (((VkUpdateBuffers*)pUpdateStruct)->count);
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ return ((VkWriteDescriptorSet*)pUpdateStruct)->count;
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
// TODO : Need to understand this case better and make sure code is correct
- return (((VkUpdateAsCopy*)pUpdateStruct)->count);
+ return ((VkCopyDescriptorSet*)pUpdateStruct)->count;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType);
layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str);
char str[1024];
switch (pUpdateStruct->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- actualType = VK_DESCRIPTOR_TYPE_SAMPLER;
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ actualType = ((VkWriteDescriptorSet*)pUpdateStruct)->descriptorType;
break;
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- actualType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- break;
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- actualType = ((VkUpdateImages*)pUpdateStruct)->descriptorType;
- break;
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- actualType = ((VkUpdateBuffers*)pUpdateStruct)->descriptorType;
- break;
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
- actualType = ((VkUpdateAsCopy*)pUpdateStruct)->descriptorType;
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
+ /* no need to validate */
+ return 1;
break;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdateStruct->sType), pUpdateStruct->sType);
static GENERIC_HEADER* shadowUpdateNode(GENERIC_HEADER* pUpdate)
{
GENERIC_HEADER* pNewNode = NULL;
- VkUpdateSamplers* pUS = NULL;
- VkUpdateSamplerTextures* pUST = NULL;
- VkUpdateBuffers* pUB = NULL;
- VkUpdateImages* pUI = NULL;
- VkUpdateAsCopy* pUAC = NULL;
+ VkWriteDescriptorSet* pWDS = NULL;
+ VkCopyDescriptorSet* pCDS = NULL;
size_t array_size = 0;
size_t base_array_size = 0;
size_t total_array_size = 0;
size_t baseBuffAddr = 0;
- VkImageViewAttachInfo** ppLocalImageViews = NULL;
- VkBufferViewAttachInfo** ppLocalBufferViews = NULL;
char str[1024];
switch (pUpdate->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- pUS = new VkUpdateSamplers;
- pNewNode = (GENERIC_HEADER*)pUS;
- memcpy(pUS, pUpdate, sizeof(VkUpdateSamplers));
- pUS->pSamplers = new VkSampler[pUS->count];
- array_size = sizeof(VkSampler) * pUS->count;
- memcpy((void*)pUS->pSamplers, ((VkUpdateSamplers*)pUpdate)->pSamplers, array_size);
- break;
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- pUST = new VkUpdateSamplerTextures;
- pNewNode = (GENERIC_HEADER*)pUST;
- memcpy(pUST, pUpdate, sizeof(VkUpdateSamplerTextures));
- pUST->pSamplerImageViews = new VkSamplerImageViewInfo[pUST->count];
- array_size = sizeof(VkSamplerImageViewInfo) * pUST->count;
- memcpy((void*)pUST->pSamplerImageViews, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews, array_size);
- for (uint32_t i = 0; i < pUST->count; i++) {
- VkImageViewAttachInfo** ppIV = (VkImageViewAttachInfo**)&pUST->pSamplerImageViews[i].pImageView;
- *ppIV = new VkImageViewAttachInfo;
- memcpy((void*)*ppIV, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews[i].pImageView, sizeof(VkImageViewAttachInfo));
- }
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ pWDS = new VkWriteDescriptorSet;
+ pNewNode = (GENERIC_HEADER*)pWDS;
+ memcpy(pWDS, pUpdate, sizeof(VkWriteDescriptorSet));
+ pWDS->pDescriptors = new VkDescriptorInfo[pWDS->count];
+ array_size = sizeof(VkDescriptorInfo) * pWDS->count;
+ memcpy((void*)pWDS->pDescriptors, ((VkWriteDescriptorSet*)pUpdate)->pDescriptors, array_size);
break;
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- pUI = new VkUpdateImages;
- pNewNode = (GENERIC_HEADER*)pUI;
- memcpy(pUI, pUpdate, sizeof(VkUpdateImages));
- pUI->pImageViews = new VkImageViewAttachInfo[pUI->count];
- array_size = (sizeof(VkImageViewAttachInfo) * pUI->count);
- memcpy((void*)pUI->pImageViews, ((VkUpdateImages*)pUpdate)->pImageViews, array_size);
- break;
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- pUB = new VkUpdateBuffers;
- pNewNode = (GENERIC_HEADER*)pUB;
- memcpy(pUB, pUpdate, sizeof(VkUpdateBuffers));
- pUB->pBufferViews = new VkBufferViewAttachInfo[pUB->count];
- array_size = (sizeof(VkBufferViewAttachInfo) * pUB->count);
- memcpy((void*)pUB->pBufferViews, ((VkUpdateBuffers*)pUpdate)->pBufferViews, array_size);
- break;
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
- pUAC = new VkUpdateAsCopy;
- pUpdate = (GENERIC_HEADER*)pUAC;
- memcpy(pUAC, pUpdate, sizeof(VkUpdateAsCopy));
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
+ pCDS = new VkCopyDescriptorSet;
+ pUpdate = (GENERIC_HEADER*)pCDS;
+ memcpy(pCDS, pUpdate, sizeof(VkCopyDescriptorSet));
break;
default:
sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdate->sType), pUpdate->sType);
pNewNode->pNext = NULL;
return pNewNode;
}
-// For given ds, update its mapping based on ppUpdateArray
-static bool32_t dsUpdate(VkDescriptorSet ds, uint32_t updateCount, const void** ppUpdateArray)
+// update DS mappings based on ppUpdateArray
+static bool32_t dsUpdate(VkStructureType type, uint32_t updateCount, const void* pUpdateArray)
{
+ const VkWriteDescriptorSet *pWDS = NULL;
+ const VkCopyDescriptorSet *pCDS = NULL;
bool32_t result = 1;
- SET_NODE* pSet = getSetNode(ds);
+
+ if (type == VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET)
+ pWDS = (const VkWriteDescriptorSet *) pUpdateArray;
+ else
+ pCDS = (const VkCopyDescriptorSet *) pUpdateArray;
+
loader_platform_thread_lock_mutex(&globalLock);
- g_lastBoundDescriptorSet = pSet->set;
LAYOUT_NODE* pLayout = NULL;
VkDescriptorSetLayoutCreateInfo* pLayoutCI = NULL;
// TODO : If pCIList is NULL, flag error
// Perform all updates
for (uint32_t i = 0; i < updateCount; i++) {
- GENERIC_HEADER* pUpdate = (GENERIC_HEADER*)ppUpdateArray[i];
+ VkDescriptorSet ds = (pWDS) ? pWDS->destSet : pCDS->destSet;
+ SET_NODE* pSet = setMap[ds]; // getSetNode() without locking
+ g_lastBoundDescriptorSet = pSet->set;
+ GENERIC_HEADER* pUpdate = (pWDS) ? (GENERIC_HEADER*) &pWDS[i] : (GENERIC_HEADER*) &pCDS[i];
pLayout = pSet->pLayout;
// First verify valid update struct
if (!validUpdateStruct(pUpdate)) {
pFreeUpdate = pShadowUpdate;
pShadowUpdate = (GENERIC_HEADER*)pShadowUpdate->pNext;
uint32_t index = 0;
- VkUpdateSamplers* pUS = NULL;
- VkUpdateSamplerTextures* pUST = NULL;
- VkUpdateImages* pUI = NULL;
- VkUpdateBuffers* pUB = NULL;
+ VkWriteDescriptorSet * pWDS = NULL;
+ VkCopyDescriptorSet * pCDS = NULL;
void** ppToFree = NULL;
switch (pFreeUpdate->sType)
{
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
- pUS = (VkUpdateSamplers*)pFreeUpdate;
- if (pUS->pSamplers)
- delete[] pUS->pSamplers;
- break;
- case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
- pUST = (VkUpdateSamplerTextures*)pFreeUpdate;
- if (pUST->pSamplerImageViews) {
- for (index = 0; index < pUST->count; index++) {
- if (pUST->pSamplerImageViews[index].pImageView) {
- delete pUST->pSamplerImageViews[index].pImageView;
- }
- }
- delete[] pUST->pSamplerImageViews;
- }
- break;
- case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
- pUI = (VkUpdateImages*)pFreeUpdate;
- if (pUI->pImageViews)
- delete[] pUI->pImageViews;
+ case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
+ pWDS = (VkWriteDescriptorSet*)pFreeUpdate;
+ if (pWDS->pDescriptors)
+ delete[] pWDS->pDescriptors;
break;
- case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
- pUB = (VkUpdateBuffers*)pFreeUpdate;
- if (pUB->pBufferViews)
- delete[] pUB->pBufferViews;
- break;
- case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
+ case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
break;
default:
assert(0);
// Common Dot dumping code
static void dsCoreDumpDot(const VkDescriptorSet ds, FILE* pOutFile)
{
+#if 0
SET_NODE* pSet = getSetNode(ds);
if (pSet) {
POOL_NODE* pPool = getPoolNode(pSet->pool);
fprintf(pOutFile, "}\n");
fprintf(pOutFile, "}\n");
}
+#endif
}
// Dump subgraph w/ DS info
static void dsDumpDot(const VkCmdBuffer cb, FILE* pOutFile)
nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
}
-VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
+VK_LAYER_EXPORT VkResult VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies)
{
- SET_NODE* pSet = getSetNode(descriptorSet);
-
- // pUpdateChain is an array of VK_UPDATE_* struct ptrs defining the mappings for the descriptors
- if (dsUpdate(descriptorSet, updateCount, ppUpdateArray)) {
- nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray);
- }
+ if (dsUpdate(VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, writeCount, pDescriptorWrites) &&
+ dsUpdate(VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET, copyCount, pDescriptorCopies))
+ return nextTable.UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
+ else
+ return VK_ERROR_UNKNOWN;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
return (void*) vkAllocDescriptorSets;
if (!strcmp(funcName, "vkClearDescriptorSets"))
return (void*) vkClearDescriptorSets;
- if (!strcmp(funcName, "vkUpdateDescriptors"))
- return (void*) vkUpdateDescriptors;
+ if (!strcmp(funcName, "vkUpdateDescriptorSets"))
+ return (void*) vkUpdateDescriptorSets;
if (!strcmp(funcName, "vkCreateDynamicViewportState"))
return (void*) vkCreateDynamicViewportState;
if (!strcmp(funcName, "vkCreateDynamicRasterState"))
typedef struct _IMAGE_NODE {
VkImageView image;
VkImageViewCreateInfo createInfo;
- VkImageViewAttachInfo attachInfo;
+ VkDescriptorInfo descriptorInfo;
} IMAGE_NODE;
typedef struct _BUFFER_NODE {
VkBufferView buffer;
VkBufferViewCreateInfo createInfo;
- VkBufferViewAttachInfo attachInfo;
+ VkDescriptorInfo descriptorInfo;
} BUFFER_NODE;
typedef struct _DYNAMIC_STATE_NODE {
nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
}
-VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
-{
- loader_platform_thread_lock_mutex(&objLock);
- ll_increment_use_count((void*)descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET);
- loader_platform_thread_unlock_mutex(&objLock);
- nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray);
-}
-
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
{
loader_platform_thread_lock_mutex(&objLock);
nextTable.ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
}
-VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
+VK_LAYER_EXPORT VkResult VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies)
{
- nextTable.UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray);
+ return nextTable.UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
return (void*) vkAllocDescriptorSets;
if (!strcmp(name, "ClearDescriptorSets"))
return (void*) vkClearDescriptorSets;
- if (!strcmp(name, "UpdateDescriptors"))
- return (void*) vkUpdateDescriptors;
+ if (!strcmp(name, "UpdateDescriptorSets"))
+ return (void*) vkUpdateDescriptorSets;
if (!strcmp(name, "CreateDynamicViewportState"))
return (void*) vkCreateDynamicViewportState;
if (!strcmp(name, "CreateDynamicRasterState"))
table->ResetDescriptorPool = (PFN_vkResetDescriptorPool) gpa(gpu, "vkResetDescriptorPool");
table->AllocDescriptorSets = (PFN_vkAllocDescriptorSets) gpa(gpu, "vkAllocDescriptorSets");
table->ClearDescriptorSets = (PFN_vkClearDescriptorSets) gpa(gpu, "vkClearDescriptorSets");
- table->UpdateDescriptors = (PFN_vkUpdateDescriptors) gpa(gpu, "vkUpdateDescriptors");
+ table->UpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) gpa(gpu, "vkUpdateDescriptorSets");
table->CreateDynamicViewportState = (PFN_vkCreateDynamicViewportState) gpa(gpu, "vkCreateDynamicViewportState");
table->CreateDynamicRasterState = (PFN_vkCreateDynamicRasterState) gpa(gpu, "vkCreateDynamicRasterState");
table->CreateDynamicColorBlendState = (PFN_vkCreateDynamicColorBlendState) gpa(gpu, "vkCreateDynamicColorBlendState");
return (void *) table->AllocDescriptorSets;
if (!strcmp(name, "ClearDescriptorSets"))
return (void *) table->ClearDescriptorSets;
- if (!strcmp(name, "UpdateDescriptors"))
- return (void *) table->UpdateDescriptors;
+ if (!strcmp(name, "UpdateDescriptorSets"))
+ return (void *) table->UpdateDescriptorSets;
if (!strcmp(name, "CreateDynamicViewportState"))
return (void *) table->CreateDynamicViewportState;
if (!strcmp(name, "CreateDynamicRasterState"))
disp->ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
}
-LOADER_EXPORT void VKAPI vkUpdateDescriptors(VkDevice device, VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
+LOADER_EXPORT VkResult VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies)
{
const VkLayerDispatchTable *disp;
disp = loader_get_dispatch(device);
- disp->UpdateDescriptors(device, descriptorSet, updateCount, ppUpdateArray);
+ return disp->UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
}
LOADER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
vkResetDescriptorPool
vkAllocDescriptorSets
vkClearDescriptorSets
- vkUpdateDescriptors
vkCreateDynamicViewportState
vkCreateDynamicRasterState
vkCreateDynamicColorBlendState
Param("uint32_t", "count"),
Param("const VkDescriptorSet*", "pDescriptorSets")]),
- Proto("void", "UpdateDescriptors",
+ Proto("VkResult", "UpdateDescriptorSets",
[Param("VkDevice", "device"),
- Param("VkDescriptorSet", "descriptorSet"),
- Param("uint32_t", "updateCount"),
- Param("const void**", "ppUpdateArray")]),
+ Param("uint32_t", "writeCount"),
+ Param("const VkWriteDescriptorSet*", "pDescriptorWrites"),
+ Param("uint32_t", "copyCount"),
+ Param("const VkCopyDescriptorSet*", "pDescriptorCopies")]),
Proto("VkResult", "CreateDynamicViewportState",
[Param("VkDevice", "device"),