From 6a3c8974948805ca58b21706be5f6f17334e206b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 4 Jan 2015 16:27:24 +0800 Subject: [PATCH] xgl: move to new resource binding model All except layout(set=) is supported. The change to pipeline_compiler_interface.{cpp,h} is ugly and fragile. It should be fixed after adding layout(set=) support. --- demos/cube.c | 171 +++++++++++++++++-------- demos/tri.c | 133 +++++++++++++------- include/xgl.h | 304 +++++++++++++++++++++++++++++---------------- include/xglDbg.h | 2 + include/xglLayer.h | 17 ++- xgl-generate.py | 11 ++ xgl.py | 73 ++++++----- 7 files changed, 459 insertions(+), 252 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index 1b6a07ef..ad3ba5da 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -232,8 +232,9 @@ struct demo { XGL_BUFFER_VIEW_ATTACH_INFO attach; } uniform_data; - XGL_DESCRIPTOR_SET dset; - + XGL_DESCRIPTOR_SET_LAYOUT desc_layout_vs; + XGL_DESCRIPTOR_SET_LAYOUT desc_layout_fs; + XGL_DESCRIPTOR_SET_LAYOUT *desc_layout_last; XGL_PIPELINE pipeline; XGL_DYNAMIC_VP_STATE_OBJECT viewport; @@ -251,6 +252,9 @@ struct demo { XGL_CMD_BUFFER cmd; + XGL_DESCRIPTOR_REGION desc_region; + XGL_DESCRIPTOR_SET desc_set; + xcb_window_t window; xcb_intern_atom_reply_t *atom_wm_delete_window; @@ -316,7 +320,7 @@ static void demo_draw_build_cmd(struct demo *demo) xglCmdBindPipeline(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS, demo->pipeline); xglCmdBindDescriptorSet(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS, - 0, demo->dset, 0); + demo->desc_set, NULL); xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport); xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster); @@ -874,36 +878,40 @@ void demo_prepare_cube_data_buffer(struct demo *demo) demo->uniform_data.attach.view = demo->uniform_data.view; } -static void demo_prepare_descriptor_set(struct demo *demo) +static void demo_prepare_descriptor_layout(struct demo *demo) { - const XGL_DESCRIPTOR_SET_CREATE_INFO descriptor_set = { - .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO, + const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO descriptor_layout_vs = { + .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .pNext = NULL, - .slots = DEMO_TEXTURE_COUNT * 2 + 2, + .descriptorType = XGL_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .count = 1, + .stageFlags = XGL_SHADER_STAGE_FLAGS_VERTEX_BIT, + .immutableSampler = XGL_NULL_HANDLE, }; + const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO descriptor_layout_fs = { + .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + .pNext = NULL, + .descriptorType = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE, + .count = DEMO_TEXTURE_COUNT, + .stageFlags = XGL_SHADER_STAGE_FLAGS_FRAGMENT_BIT, + .immutableSampler = XGL_NULL_HANDLE, + }; + const uint32_t bind_point = 0; XGL_RESULT err; - err = xglCreateDescriptorSet(demo->device, &descriptor_set, &demo->dset); + err = xglCreateDescriptorSetLayout(demo->device, + XGL_SHADER_STAGE_FLAGS_VERTEX_BIT, &bind_point, + XGL_NULL_HANDLE, &descriptor_layout_vs, + &demo->desc_layout_vs); assert(!err); - xglBeginDescriptorSetUpdate(demo->dset); - xglClearDescriptorSetSlots(demo->dset, 0, DEMO_TEXTURE_COUNT * 2 + 2); - -// xglAttachMemoryViewDescriptors(demo->dset, 0, 1, &demo->vertices.view); - - xglAttachBufferViewDescriptors(demo->dset, 0, 1, &demo->uniform_data.attach); - - XGL_IMAGE_VIEW_ATTACH_INFO image_view; - - image_view.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO; - image_view.pNext = NULL; - image_view.view = demo->textures[0].view; - image_view.layout = XGL_IMAGE_LAYOUT_GENERAL; - - xglAttachSamplerDescriptors(demo->dset, 1, 1, &demo->textures[0].sampler); - xglAttachImageViewDescriptors(demo->dset, 2, 1, &image_view); + err = xglCreateDescriptorSetLayout(demo->device, + XGL_SHADER_STAGE_FLAGS_FRAGMENT_BIT, &bind_point, + demo->desc_layout_vs, &descriptor_layout_fs, + &demo->desc_layout_fs); + assert(!err); - xglEndDescriptorSetUpdate(demo->dset); + demo->desc_layout_last = &demo->desc_layout_fs; } static XGL_SHADER demo_prepare_shader(struct demo *demo, @@ -1047,12 +1055,11 @@ static void demo_prepare_pipeline(struct demo *demo) XGL_PIPELINE_SHADER_STAGE_CREATE_INFO fs; XGL_PIPELINE_VP_STATE_CREATE_INFO vp; XGL_PIPELINE_MS_STATE_CREATE_INFO ms; - XGL_DESCRIPTOR_SLOT_INFO vs_slots[3]; - XGL_DESCRIPTOR_SLOT_INFO fs_slots[3]; XGL_RESULT err; memset(&pipeline, 0, sizeof(pipeline)); pipeline.sType = XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + pipeline.lastSetLayout = *demo->desc_layout_last; memset(&ia, 0, sizeof(ia)); ia.sType = XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO; @@ -1091,39 +1098,17 @@ static void demo_prepare_pipeline(struct demo *demo) ds.stencilTestEnable = XGL_FALSE; ds.front = ds.back; - memset(&vs_slots, 0, sizeof(vs_slots)); - vs_slots[0].slotObjectType = XGL_SLOT_SHADER_RESOURCE; - vs_slots[0].shaderEntityIndex = 0; - - memset(&fs_slots, 0, sizeof(fs_slots)); - fs_slots[1].slotObjectType = XGL_SLOT_SHADER_SAMPLER; - fs_slots[1].shaderEntityIndex = 0; - fs_slots[2].slotObjectType = XGL_SLOT_SHADER_TEXTURE_RESOURCE; - fs_slots[2].shaderEntityIndex = 0; - memset(&vs, 0, sizeof(vs)); vs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vs.shader.stage = XGL_SHADER_STAGE_VERTEX; vs.shader.shader = demo_prepare_vs(demo); assert(vs.shader.shader != NULL); - XGL_DESCRIPTOR_SET_MAPPING ds_mapping1; - ds_mapping1.descriptorCount = 3; - ds_mapping1.pDescriptorInfo = vs_slots; - vs.shader.pDescriptorSetMapping = &ds_mapping1; - vs.shader.linkConstBufferCount = 0; - vs.shader.descriptorSetMappingCount = 1; memset(&fs, 0, sizeof(fs)); fs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; fs.shader.stage = XGL_SHADER_STAGE_FRAGMENT; fs.shader.shader = demo_prepare_fs(demo); assert(fs.shader.shader != NULL); - XGL_DESCRIPTOR_SET_MAPPING ds_mapping2; - ds_mapping2.descriptorCount = 3; - ds_mapping2.pDescriptorInfo = fs_slots; - fs.shader.pDescriptorSetMapping = &ds_mapping2; - fs.shader.linkConstBufferCount = 0; - fs.shader.descriptorSetMappingCount = 1; memset(&ms, 0, sizeof(ms)); ms.sType = XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO; @@ -1193,6 +1178,82 @@ static void demo_prepare_dynamic_states(struct demo *demo) assert(!err); } +static void demo_prepare_descriptor_region(struct demo *demo) +{ + const XGL_DESCRIPTOR_TYPE_COUNT type_counts[2] = { + [0] = { + .type = XGL_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .count = 1, + }, + [1] = { + .type = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE, + .count = DEMO_TEXTURE_COUNT, + }, + }; + const XGL_DESCRIPTOR_REGION_CREATE_INFO descriptor_region = { + .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_REGION_CREATE_INFO, + .pNext = NULL, + .count = 2, + .pTypeCount = type_counts, + }; + XGL_RESULT err; + + err = xglCreateDescriptorRegion(demo->device, + XGL_DESCRIPTOR_REGION_USAGE_ONE_SHOT, 1, + &descriptor_region, &demo->desc_region); + assert(!err); +} + +static void demo_prepare_descriptor_set(struct demo *demo) +{ + const XGL_BUFFER_VIEW_ATTACH_INFO *view_info_vs = + &demo->uniform_data.attach; + XGL_IMAGE_VIEW_ATTACH_INFO view_info[DEMO_TEXTURE_COUNT]; + XGL_SAMPLER_IMAGE_VIEW_INFO combined_info[DEMO_TEXTURE_COUNT]; + XGL_UPDATE_SAMPLER_TEXTURES update_fs; + XGL_UPDATE_BUFFERS update_vs; + XGL_RESULT err; + uint32_t count; + XGL_UINT i; + + for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { + view_info[i].sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO; + view_info[i].pNext = NULL; + view_info[i].view = demo->textures[i].view, + view_info[i].layout = XGL_IMAGE_LAYOUT_GENERAL; + + combined_info[i].pSampler = demo->textures[i].sampler; + combined_info[i].pImageView = &view_info[i]; + } + + memset(&update_vs, 0, sizeof(update_vs)); + update_vs.sType = XGL_STRUCTURE_TYPE_UPDATE_BUFFERS; + update_vs.pNext = &update_fs; + update_vs.descriptorType = XGL_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + update_vs.count = 1; + update_vs.pBufferViews = &view_info_vs; + + memset(&update_fs, 0, sizeof(update_fs)); + update_fs.sType = XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES; + update_fs.index = 1; + update_fs.count = DEMO_TEXTURE_COUNT; + update_fs.pSamplerImageViews = combined_info; + + err = xglAllocDescriptorSets(demo->desc_region, + XGL_DESCRIPTOR_SET_USAGE_STATIC, + 1, demo->desc_layout_last, + &demo->desc_set, &count); + assert(!err && count == 1); + + xglBeginDescriptorRegionUpdate(demo->device, + XGL_DESCRIPTOR_UPDATE_MODE_FASTEST); + + xglClearDescriptorSets(demo->desc_region, 1, &demo->desc_set); + xglUpdateDescriptors(demo->desc_set, &update_vs); + + xglEndDescriptorRegionUpdate(demo->device, demo->cmd); +} + static void demo_prepare(struct demo *demo) { const XGL_CMD_BUFFER_CREATE_INFO cmd = { @@ -1207,13 +1268,16 @@ static void demo_prepare(struct demo *demo) demo_prepare_depth(demo); demo_prepare_textures(demo); demo_prepare_cube_data_buffer(demo); - demo_prepare_descriptor_set(demo); + demo_prepare_descriptor_layout(demo); demo_prepare_pipeline(demo); demo_prepare_dynamic_states(demo); err = xglCreateCommandBuffer(demo->device, &cmd, &demo->cmd); assert(!err); + + demo_prepare_descriptor_region(demo); + demo_prepare_descriptor_set(demo); } static void demo_handle_event(struct demo *demo, @@ -1420,6 +1484,9 @@ static void demo_cleanup(struct demo *demo) { XGL_UINT i; + xglDestroyObject(demo->desc_set); + xglDestroyObject(demo->desc_region); + xglDestroyObject(demo->cmd); xglDestroyObject(demo->viewport); @@ -1428,8 +1495,8 @@ static void demo_cleanup(struct demo *demo) xglDestroyObject(demo->depth_stencil); xglDestroyObject(demo->pipeline); - - xglDestroyObject(demo->dset); + xglDestroyObject(demo->desc_layout_fs); + xglDestroyObject(demo->desc_layout_vs); // xglFreeMemory(demo->vertices.mem); diff --git a/demos/tri.c b/demos/tri.c index 8d746987..ee085dcb 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -64,8 +64,7 @@ struct demo { XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attrs[2]; } vertices; - XGL_DESCRIPTOR_SET dset; - + XGL_DESCRIPTOR_SET_LAYOUT desc_layout; XGL_PIPELINE pipeline; XGL_DYNAMIC_VP_STATE_OBJECT viewport; @@ -75,6 +74,9 @@ struct demo { XGL_CMD_BUFFER cmd; + XGL_DESCRIPTOR_REGION desc_region; + XGL_DESCRIPTOR_SET desc_set; + xcb_window_t window; xcb_intern_atom_reply_t *atom_wm_delete_window; @@ -140,7 +142,7 @@ static void demo_draw_build_cmd(struct demo *demo) xglCmdBindPipeline(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS, demo->pipeline); xglCmdBindDescriptorSet(demo->cmd, XGL_PIPELINE_BIND_POINT_GRAPHICS, - 0, demo->dset, 0); + demo->desc_set, NULL); xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_VIEWPORT, demo->viewport); xglCmdBindDynamicStateObject(demo->cmd, XGL_STATE_BIND_RASTER, demo->raster); @@ -543,37 +545,24 @@ static void demo_prepare_vertices(struct demo *demo) demo->vertices.vi_attrs[1].offsetInBytes = sizeof(float) * 3; } -static void demo_prepare_descriptor_set(struct demo *demo) +static void demo_prepare_descriptor_layout(struct demo *demo) { - const XGL_DESCRIPTOR_SET_CREATE_INFO descriptor_set = { - .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO, + const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO descriptor_layout = { + .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .pNext = NULL, - .slots = DEMO_TEXTURE_COUNT * 2, + .descriptorType = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE, + .count = DEMO_TEXTURE_COUNT, + .stageFlags = XGL_SHADER_STAGE_FLAGS_FRAGMENT_BIT, + .immutableSampler = XGL_NULL_HANDLE, }; + const uint32_t bind_point = 0; XGL_RESULT err; - XGL_UINT i; - err = xglCreateDescriptorSet(demo->device, &descriptor_set, &demo->dset); + err = xglCreateDescriptorSetLayout(demo->device, + XGL_SHADER_STAGE_FLAGS_ALL, &bind_point, + XGL_NULL_HANDLE, &descriptor_layout, + &demo->desc_layout); assert(!err); - - xglBeginDescriptorSetUpdate(demo->dset); - xglClearDescriptorSetSlots(demo->dset, 0, DEMO_TEXTURE_COUNT * 2); - - for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { - const XGL_IMAGE_VIEW_ATTACH_INFO image_view = { - .sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO, - .pNext = NULL, - .view = demo->textures[i].view, - .layout = XGL_IMAGE_LAYOUT_GENERAL, - }; - - xglAttachSamplerDescriptors(demo->dset, 2 * i, 1, - &demo->textures[i].sampler); - xglAttachImageViewDescriptors(demo->dset, 2 * i + 1, 1, - &image_view); - } - - xglEndDescriptorSetUpdate(demo->dset); } static XGL_SHADER demo_prepare_shader(struct demo *demo, @@ -653,12 +642,11 @@ static void demo_prepare_pipeline(struct demo *demo) XGL_PIPELINE_SHADER_STAGE_CREATE_INFO fs; XGL_PIPELINE_VP_STATE_CREATE_INFO vp; XGL_PIPELINE_MS_STATE_CREATE_INFO ms; - XGL_DESCRIPTOR_SLOT_INFO fs_slots[DEMO_TEXTURE_COUNT * 2]; XGL_RESULT err; - XGL_UINT i; memset(&pipeline, 0, sizeof(pipeline)); pipeline.sType = XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + pipeline.lastSetLayout = demo->desc_layout; vi = demo->vertices.vi; @@ -701,30 +689,16 @@ static void demo_prepare_pipeline(struct demo *demo) ds.stencilTestEnable = XGL_FALSE; ds.front = ds.back; - memset(&fs_slots, 0, sizeof(fs_slots)); - for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { - fs_slots[2 * i].slotObjectType = XGL_SLOT_SHADER_SAMPLER; - fs_slots[2 * i].shaderEntityIndex = i; - fs_slots[2 * i + 1].slotObjectType = XGL_SLOT_SHADER_TEXTURE_RESOURCE; - fs_slots[2 * i + 1].shaderEntityIndex = i; - } - memset(&vs, 0, sizeof(vs)); vs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; vs.shader.stage = XGL_SHADER_STAGE_VERTEX; vs.shader.shader = demo_prepare_vs(demo); vs.shader.linkConstBufferCount = 0; - vs.shader.descriptorSetMappingCount = 0; memset(&fs, 0, sizeof(fs)); fs.sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; fs.shader.stage = XGL_SHADER_STAGE_FRAGMENT; fs.shader.shader = demo_prepare_fs(demo); - XGL_DESCRIPTOR_SET_MAPPING ds_mapping; - ds_mapping.descriptorCount = DEMO_TEXTURE_COUNT * 2; - ds_mapping.pDescriptorInfo = fs_slots; - fs.shader.descriptorSetMappingCount = 1; - fs.shader.pDescriptorSetMapping = &ds_mapping; memset(&ms, 0, sizeof(ms)); ms.sType = XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO; @@ -796,6 +770,65 @@ static void demo_prepare_dynamic_states(struct demo *demo) assert(!err); } +static void demo_prepare_descriptor_region(struct demo *demo) +{ + const XGL_DESCRIPTOR_TYPE_COUNT type_count = { + .type = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE, + .count = DEMO_TEXTURE_COUNT, + }; + const XGL_DESCRIPTOR_REGION_CREATE_INFO descriptor_region = { + .sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_REGION_CREATE_INFO, + .pNext = NULL, + .count = 1, + .pTypeCount = &type_count, + }; + XGL_RESULT err; + + err = xglCreateDescriptorRegion(demo->device, + XGL_DESCRIPTOR_REGION_USAGE_ONE_SHOT, 1, + &descriptor_region, &demo->desc_region); + assert(!err); +} + +static void demo_prepare_descriptor_set(struct demo *demo) +{ + XGL_IMAGE_VIEW_ATTACH_INFO view_info[DEMO_TEXTURE_COUNT]; + XGL_SAMPLER_IMAGE_VIEW_INFO combined_info[DEMO_TEXTURE_COUNT]; + XGL_UPDATE_SAMPLER_TEXTURES update; + XGL_RESULT err; + uint32_t count; + XGL_UINT i; + + for (i = 0; i < DEMO_TEXTURE_COUNT; i++) { + view_info[i].sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO; + view_info[i].pNext = NULL; + view_info[i].view = demo->textures[i].view, + view_info[i].layout = XGL_IMAGE_LAYOUT_GENERAL; + + combined_info[i].pSampler = demo->textures[i].sampler; + combined_info[i].pImageView = &view_info[i]; + } + + memset(&update, 0, sizeof(update)); + update.sType = XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES; + update.count = DEMO_TEXTURE_COUNT; + update.pSamplerImageViews = combined_info; + + err = xglAllocDescriptorSets(demo->desc_region, + XGL_DESCRIPTOR_SET_USAGE_STATIC, + 1, &demo->desc_layout, + &demo->desc_set, &count); + assert(!err && count == 1); + + xglBeginDescriptorRegionUpdate(demo->device, + XGL_DESCRIPTOR_UPDATE_MODE_FASTEST); + + xglClearDescriptorSets(demo->desc_region, 1, &demo->desc_set); + xglUpdateDescriptors(demo->desc_set, &update); + + xglEndDescriptorRegionUpdate(demo->device, demo->cmd); +} + static void demo_prepare(struct demo *demo) { const XGL_CMD_BUFFER_CREATE_INFO cmd = { @@ -810,13 +843,15 @@ static void demo_prepare(struct demo *demo) demo_prepare_depth(demo); demo_prepare_textures(demo); demo_prepare_vertices(demo); - demo_prepare_descriptor_set(demo); - + demo_prepare_descriptor_layout(demo); demo_prepare_pipeline(demo); demo_prepare_dynamic_states(demo); err = xglCreateCommandBuffer(demo->device, &cmd, &demo->cmd); assert(!err); + + demo_prepare_descriptor_region(demo); + demo_prepare_descriptor_set(demo); } static void demo_handle_event(struct demo *demo, @@ -989,6 +1024,9 @@ static void demo_cleanup(struct demo *demo) { XGL_UINT i; + xglDestroyObject(demo->desc_set); + xglDestroyObject(demo->desc_region); + xglDestroyObject(demo->cmd); xglDestroyObject(demo->viewport); @@ -997,8 +1035,7 @@ static void demo_cleanup(struct demo *demo) xglDestroyObject(demo->depth_stencil); xglDestroyObject(demo->pipeline); - - xglDestroyObject(demo->dset); + xglDestroyObject(demo->desc_layout); xglBindObjectMemory(demo->vertices.buf, XGL_NULL_HANDLE, 0); xglDestroyObject(demo->vertices.buf); diff --git a/include/xgl.h b/include/xgl.h index 9532a6c5..03a09132 100644 --- a/include/xgl.h +++ b/include/xgl.h @@ -92,6 +92,8 @@ XGL_DEFINE_SUBCLASS_HANDLE(XGL_PIPELINE, XGL_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_PIPELINE_DELTA, XGL_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_SAMPLER, XGL_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_DESCRIPTOR_SET, XGL_OBJECT) +XGL_DEFINE_SUBCLASS_HANDLE(XGL_DESCRIPTOR_SET_LAYOUT, XGL_OBJECT) +XGL_DEFINE_SUBCLASS_HANDLE(XGL_DESCRIPTOR_REGION, XGL_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_STATE_OBJECT, XGL_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_VP_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT) XGL_DEFINE_SUBCLASS_HANDLE(XGL_DYNAMIC_RS_STATE_OBJECT, XGL_DYNAMIC_STATE_OBJECT) @@ -276,24 +278,59 @@ typedef enum _XGL_CHANNEL_SWIZZLE XGL_MAX_ENUM(_XGL_CHANNEL_SWIZZLE) } XGL_CHANNEL_SWIZZLE; -typedef enum _XGL_DESCRIPTOR_SET_SLOT_TYPE +typedef enum _XGL_DESCRIPTOR_TYPE { - XGL_SLOT_UNUSED = 0x00000000, - XGL_SLOT_SHADER_RESOURCE = 0x00000001, - XGL_SLOT_SHADER_UAV = 0x00000002, - XGL_SLOT_SHADER_SAMPLER = 0x00000003, - XGL_SLOT_NEXT_DESCRIPTOR_SET = 0x00000004, + XGL_DESCRIPTOR_TYPE_SAMPLER = 0x00000000, + XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE = 0x00000001, + XGL_DESCRIPTOR_TYPE_TEXTURE = 0x00000002, + XGL_DESCRIPTOR_TYPE_TEXTURE_BUFFER = 0x00000003, + XGL_DESCRIPTOR_TYPE_IMAGE = 0x00000004, + XGL_DESCRIPTOR_TYPE_IMAGE_BUFFER = 0x00000005, + XGL_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 0x00000006, + XGL_DESCRIPTOR_TYPE_SHADER_STORAGE_BUFFER = 0x00000007, + XGL_DESCRIPTOR_TYPE_RAW_BUFFER = 0x00000008, + XGL_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 0x00000009, + XGL_DESCRIPTOR_TYPE_SHADER_STORAGE_BUFFER_DYNAMIC = 0x0000000a, + XGL_DESCRIPTOR_TYPE_RAW_BUFFER_DYNAMIC = 0x0000000b, - // LUNARG CHANGE BEGIN - differentiate between textures and buffers - XGL_SLOT_SHADER_TEXTURE_RESOURCE = 0x00000005, + XGL_DESCRIPTOR_TYPE_BEGIN_RANGE = XGL_DESCRIPTOR_TYPE_SAMPLER, + XGL_DESCRIPTOR_TYPE_END_RANGE = XGL_DESCRIPTOR_TYPE_RAW_BUFFER_DYNAMIC, + XGL_NUM_DESCRIPTOR_TYPE = (XGL_DESCRIPTOR_TYPE_END_RANGE - XGL_DESCRIPTOR_TYPE_BEGIN_RANGE + 1), + XGL_MAX_ENUM(_XGL_DESCRIPTOR_TYPE) +} XGL_DESCRIPTOR_TYPE; - XGL_DESCRIPTOR_SET_SLOT_TYPE_BEGIN_RANGE = XGL_SLOT_UNUSED, - XGL_DESCRIPTOR_SET_SLOT_TYPE_END_RANGE = XGL_SLOT_SHADER_TEXTURE_RESOURCE, - // LUNARG CHANGE END +typedef enum _XGL_DESCRIPTOR_REGION_USAGE +{ + XGL_DESCRIPTOR_REGION_USAGE_ONE_SHOT = 0x00000000, + XGL_DESCRIPTOR_REGION_USAGE_DYNAMIC = 0x00000001, + + XGL_DESCRIPTOR_REGION_USAGE_BEGIN_RANGE = XGL_DESCRIPTOR_REGION_USAGE_ONE_SHOT, + XGL_DESCRIPTOR_REGION_USAGE_END_RANGE = XGL_DESCRIPTOR_REGION_USAGE_DYNAMIC, + XGL_NUM_DESCRIPTOR_REGION_USAGE = (XGL_DESCRIPTOR_REGION_USAGE_END_RANGE - XGL_DESCRIPTOR_REGION_USAGE_BEGIN_RANGE + 1), + XGL_MAX_ENUM(_XGL_DESCRIPTOR_REGION_USAGE) +} XGL_DESCRIPTOR_REGION_USAGE; + +typedef enum _XGL_DESCRIPTOR_UPDATE_MODE +{ + XGL_DESCRIPTOR_UDPATE_MODE_COPY = 0x00000000, + XGL_DESCRIPTOR_UPDATE_MODE_FASTEST = 0x00000001, + + XGL_DESCRIPTOR_UPDATE_MODE_BEGIN_RANGE = XGL_DESCRIPTOR_UDPATE_MODE_COPY, + XGL_DESCRIPTOR_UPDATE_MODE_END_RANGE = XGL_DESCRIPTOR_UPDATE_MODE_FASTEST, + XGL_NUM_DESCRIPTOR_UPDATE_MODE = (XGL_DESCRIPTOR_UPDATE_MODE_END_RANGE - XGL_DESCRIPTOR_UPDATE_MODE_BEGIN_RANGE + 1), + XGL_MAX_ENUM(_XGL_DESCRIPTOR_UPDATE_MODE) +} XGL_DESCRIPTOR_UPDATE_MODE; + +typedef enum _XGL_DESCRIPTOR_SET_USAGE +{ + XGL_DESCRIPTOR_SET_USAGE_ONE_SHOT = 0x00000000, + XGL_DESCRIPTOR_SET_USAGE_STATIC = 0x00000001, - XGL_NUM_DESCRIPTOR_SET_SLOT_TYPE = (XGL_DESCRIPTOR_SET_SLOT_TYPE_END_RANGE - XGL_DESCRIPTOR_SET_SLOT_TYPE_BEGIN_RANGE + 1), - XGL_MAX_ENUM(_XGL_DESCRIPTOR_SET_SLOT_TYPE) -} XGL_DESCRIPTOR_SET_SLOT_TYPE; + XGL_DESCRIPTOR_SET_USAGE_BEGIN_RANGE = XGL_DESCRIPTOR_SET_USAGE_ONE_SHOT, + XGL_DESCRIPTOR_SET_USAGE_END_RANGE = XGL_DESCRIPTOR_SET_USAGE_STATIC, + XGL_NUM_DESCRIPTOR_SET_USAGE = (XGL_DESCRIPTOR_SET_USAGE_END_RANGE - XGL_DESCRIPTOR_SET_USAGE_BEGIN_RANGE + 1), + XGL_MAX_ENUM(_XGL_DESCRIPTOR_SET_USAGE) +} XGL_DESCRIPTOR_SET_USAGE; typedef enum _XGL_QUERY_TYPE { @@ -854,6 +891,19 @@ typedef enum _XGL_PIPELINE_SHADER_STAGE XGL_MAX_ENUM(_XGL_PIPELINE_SHADER_STAGE) } XGL_PIPELINE_SHADER_STAGE; +typedef enum _XGL_SHADER_STAGE_FLAGS +{ + XGL_SHADER_STAGE_FLAGS_VERTEX_BIT = 0x00000001, + XGL_SHADER_STAGE_FLAGS_TESS_CONTROL_BIT = 0x00000002, + XGL_SHADER_STAGE_FLAGS_TESS_EVALUATION_BIT = 0x00000004, + XGL_SHADER_STAGE_FLAGS_GEOMETRY_BIT = 0x00000008, + XGL_SHADER_STAGE_FLAGS_FRAGMENT_BIT = 0x00000010, + XGL_SHADER_STAGE_FLAGS_COMPUTE_BIT = 0x00000020, + + XGL_SHADER_STAGE_FLAGS_ALL = 0x7FFFFFFF, + XGL_MAX_ENUM(_XGL_SHADER_STAGE_FLAGS) +} XGL_SHADER_STAGE_FLAGS; + // Graphics workload submit type. Used for rendering workloads. typedef enum _XGL_RENDER_PASS_OPERATION { @@ -882,7 +932,7 @@ typedef enum _XGL_STRUCTURE_TYPE XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO = 12, XGL_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 13, XGL_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 14, - XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO = 15, + XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 15, XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO = 16, XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO = 17, XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO = 18, @@ -915,6 +965,12 @@ typedef enum _XGL_STRUCTURE_TYPE XGL_STRUCTURE_TYPE_MEMORY_BARRIER = 45, XGL_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 46, XGL_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 47, + XGL_STRUCTURE_TYPE_DESCRIPTOR_REGION_CREATE_INFO = 48, + XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS = 49, + XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES = 50, + XGL_STRUCTURE_TYPE_UPDATE_IMAGES = 51, + XGL_STRUCTURE_TYPE_UPDATE_BUFFERS = 52, + XGL_STRUCTURE_TYPE_UPDATE_AS_COPY = 53, XGL_MAX_ENUM(_XGL_STRUCTURE_TYPE) } XGL_STRUCTURE_TYPE; @@ -1299,6 +1355,60 @@ typedef struct _XGL_IMAGE_VIEW_ATTACH_INFO XGL_IMAGE_LAYOUT layout; } XGL_IMAGE_VIEW_ATTACH_INFO; +typedef struct _XGL_UPDATE_SAMPLERS +{ + XGL_STRUCTURE_TYPE sType; + XGL_VOID* pNext; + XGL_UINT index; + XGL_UINT count; + const XGL_SAMPLER* pSamplers; +} XGL_UPDATE_SAMPLERS; + +typedef struct _XGL_SAMPLER_IMAGE_VIEW_INFO +{ + XGL_SAMPLER pSampler; + const XGL_IMAGE_VIEW_ATTACH_INFO* pImageView; +} XGL_SAMPLER_IMAGE_VIEW_INFO; + +typedef struct _XGL_UPDATE_SAMPLER_TEXTURES +{ + XGL_STRUCTURE_TYPE sType; + XGL_VOID* pNext; + XGL_UINT index; + XGL_UINT count; + const XGL_SAMPLER_IMAGE_VIEW_INFO* pSamplerImageViews; +} XGL_UPDATE_SAMPLER_TEXTURES; + +typedef struct _XGL_UPDATE_IMAGES +{ + XGL_STRUCTURE_TYPE sType; + XGL_VOID* pNext; + XGL_DESCRIPTOR_TYPE descriptorType; + XGL_UINT index; + XGL_UINT count; + const XGL_IMAGE_VIEW_ATTACH_INFO* const* pImageViews; +} XGL_UPDATE_IMAGES; + +typedef struct _XGL_UPDATE_BUFFERS +{ + XGL_STRUCTURE_TYPE sType; + XGL_VOID* pNext; + XGL_DESCRIPTOR_TYPE descriptorType; + XGL_UINT index; + XGL_UINT count; + const XGL_BUFFER_VIEW_ATTACH_INFO* const* pBufferViews; +} XGL_UPDATE_BUFFERS; + +typedef struct _XGL_UPDATE_AS_COPY +{ + XGL_STRUCTURE_TYPE sType; + const XGL_VOID* pNext; + XGL_DESCRIPTOR_TYPE descriptorType; + XGL_DESCRIPTOR_SET descriptorSet; + XGL_UINT descriptorIndex; + XGL_UINT count; +} XGL_UPDATE_AS_COPY; + typedef struct _XGL_BUFFER_CREATE_INFO { XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_BUFFER_CREATE_INFO @@ -1531,23 +1641,29 @@ typedef struct _XGL_SHADER_CREATE_INFO XGL_FLAGS flags; // Reserved } XGL_SHADER_CREATE_INFO; -struct _XGL_DESCRIPTOR_SET_MAPPING; +typedef struct _XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO +{ + XGL_STRUCTURE_TYPE sType; + const XGL_VOID* pNext; + XGL_DESCRIPTOR_TYPE descriptorType; + XGL_UINT count; + XGL_FLAGS stageFlags; // XGL_SHADER_STAGE_FLAGS + XGL_SAMPLER immutableSampler; +} XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; -typedef struct _XGL_DESCRIPTOR_SLOT_INFO +typedef struct _XGL_DESCRIPTOR_TYPE_COUNT { - XGL_DESCRIPTOR_SET_SLOT_TYPE slotObjectType; - union - { - XGL_UINT shaderEntityIndex;// Shader IL slot index for given entity type - const struct _XGL_DESCRIPTOR_SET_MAPPING* pNextLevelSet; // Pointer to next descriptor set level - }; -} XGL_DESCRIPTOR_SLOT_INFO; + XGL_DESCRIPTOR_TYPE type; + XGL_UINT count; +} XGL_DESCRIPTOR_TYPE_COUNT; -typedef struct _XGL_DESCRIPTOR_SET_MAPPING +typedef struct _XGL_DESCRIPTOR_REGION_CREATE_INFO { - XGL_UINT descriptorCount; - const XGL_DESCRIPTOR_SLOT_INFO* pDescriptorInfo; -} XGL_DESCRIPTOR_SET_MAPPING; + XGL_STRUCTURE_TYPE sType; + const XGL_VOID* pNext; + XGL_UINT count; + const XGL_DESCRIPTOR_TYPE_COUNT* pTypeCount; +} XGL_DESCRIPTOR_REGION_CREATE_INFO; typedef struct _XGL_LINK_CONST_BUFFER { @@ -1556,21 +1672,12 @@ typedef struct _XGL_LINK_CONST_BUFFER const XGL_VOID* pBufferData; } XGL_LINK_CONST_BUFFER; -typedef struct _XGL_DYNAMIC_BUFFER_VIEW_SLOT_INFO -{ - XGL_DESCRIPTOR_SET_SLOT_TYPE slotObjectType; - XGL_UINT shaderEntityIndex; -} XGL_DYNAMIC_BUFFER_VIEW_SLOT_INFO; - typedef struct _XGL_PIPELINE_SHADER { XGL_PIPELINE_SHADER_STAGE stage; XGL_SHADER shader; - XGL_UINT descriptorSetMappingCount; - XGL_DESCRIPTOR_SET_MAPPING* pDescriptorSetMapping; XGL_UINT linkConstBufferCount; const XGL_LINK_CONST_BUFFER* pLinkConstBufferInfo; - XGL_DYNAMIC_BUFFER_VIEW_SLOT_INFO dynamicBufferViewMapping; } XGL_PIPELINE_SHADER; typedef struct _XGL_COMPUTE_PIPELINE_CREATE_INFO @@ -1579,6 +1686,7 @@ typedef struct _XGL_COMPUTE_PIPELINE_CREATE_INFO const XGL_VOID* pNext; // Pointer to next structure XGL_PIPELINE_SHADER cs; XGL_FLAGS flags; // XGL_PIPELINE_CREATE_FLAGS + XGL_DESCRIPTOR_SET_LAYOUT lastSetLayout; } XGL_COMPUTE_PIPELINE_CREATE_INFO; typedef struct _XGL_VERTEX_INPUT_BINDING_DESCRIPTION @@ -1723,6 +1831,7 @@ typedef struct _XGL_GRAPHICS_PIPELINE_CREATE_INFO XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO const XGL_VOID* pNext; // Pointer to next structure XGL_FLAGS flags; // XGL_PIPELINE_CREATE_FLAGS + XGL_DESCRIPTOR_SET_LAYOUT lastSetLayout; } XGL_GRAPHICS_PIPELINE_CREATE_INFO; typedef struct _XGL_SAMPLER_CREATE_INFO @@ -1743,19 +1852,6 @@ typedef struct _XGL_SAMPLER_CREATE_INFO XGL_BORDER_COLOR_TYPE borderColorType; } XGL_SAMPLER_CREATE_INFO; -typedef struct _XGL_DESCRIPTOR_SET_CREATE_INFO -{ - XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO - const XGL_VOID* pNext; // Pointer to next structure - XGL_UINT slots; -} XGL_DESCRIPTOR_SET_CREATE_INFO; - -typedef struct _XGL_DESCRIPTOR_SET_ATTACH_INFO -{ - XGL_DESCRIPTOR_SET descriptorSet; - XGL_UINT slotOffset; -} XGL_DESCRIPTOR_SET_ATTACH_INFO; - typedef struct _XGL_DYNAMIC_VP_STATE_CREATE_INFO { XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO @@ -2015,14 +2111,14 @@ typedef XGL_RESULT (XGLAPI *xglStorePipelineType)(XGL_PIPELINE pipeline, XGL_SIZ typedef XGL_RESULT (XGLAPI *xglLoadPipelineType)(XGL_DEVICE device, XGL_SIZE dataSize, const XGL_VOID* pData, XGL_PIPELINE* pPipeline); typedef XGL_RESULT (XGLAPI *xglCreatePipelineDeltaType)(XGL_DEVICE device, XGL_PIPELINE p1, XGL_PIPELINE p2, XGL_PIPELINE_DELTA* delta); typedef XGL_RESULT (XGLAPI *xglCreateSamplerType)(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler); -typedef XGL_RESULT (XGLAPI *xglCreateDescriptorSetType)(XGL_DEVICE device, const XGL_DESCRIPTOR_SET_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_SET* pDescriptorSet); -typedef XGL_VOID (XGLAPI *xglBeginDescriptorSetUpdateType)(XGL_DESCRIPTOR_SET descriptorSet); -typedef XGL_VOID (XGLAPI *xglEndDescriptorSetUpdateType)(XGL_DESCRIPTOR_SET descriptorSet); -typedef XGL_VOID (XGLAPI *xglAttachSamplerDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_SAMPLER* pSamplers); -typedef XGL_VOID (XGLAPI *xglAttachImageViewDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews); -typedef XGL_VOID (XGLAPI *xglAttachBufferViewDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferViews); -typedef XGL_VOID (XGLAPI *xglAttachNestedDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets); -typedef XGL_VOID (XGLAPI *xglClearDescriptorSetSlotsType)(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount); +typedef XGL_RESULT (XGLAPI *xglCreateDescriptorSetLayoutType)(XGL_DEVICE device, XGL_FLAGS stageFlags, const XGL_UINT* pSetBindPoints, XGL_DESCRIPTOR_SET_LAYOUT priorSetLayout, const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pSetLayoutInfoList, XGL_DESCRIPTOR_SET_LAYOUT* pSetLayout); +typedef XGL_RESULT (XGLAPI *xglBeginDescriptorRegionUpdateType)(XGL_DEVICE device, XGL_DESCRIPTOR_UPDATE_MODE updateMode); +typedef XGL_RESULT (XGLAPI *xglEndDescriptorRegionUpdateType)(XGL_DEVICE device, XGL_CMD_BUFFER cmd); +typedef XGL_RESULT (XGLAPI *xglCreateDescriptorRegionType)(XGL_DEVICE device, XGL_DESCRIPTOR_REGION_USAGE regionUsage, XGL_UINT maxSets, const XGL_DESCRIPTOR_REGION_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_REGION* pDescriptorRegion); +typedef XGL_RESULT (XGLAPI *xglClearDescriptorRegionType)(XGL_DESCRIPTOR_REGION descriptorRegion); +typedef XGL_RESULT (XGLAPI *xglAllocDescriptorSetsType)(XGL_DESCRIPTOR_REGION descriptorRegion, XGL_DESCRIPTOR_SET_USAGE setUsage, XGL_UINT count, const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts, XGL_DESCRIPTOR_SET* pDescriptorSets, XGL_UINT* pCount); +typedef XGL_VOID (XGLAPI *xglClearDescriptorSetsType)(XGL_DESCRIPTOR_REGION descriptorRegion, XGL_UINT count, const XGL_DESCRIPTOR_SET* pDescriptorSets); +typedef XGL_VOID (XGLAPI *xglUpdateDescriptorsType)(XGL_DESCRIPTOR_SET descriptorSet, const XGL_VOID* pUpdateChain); typedef XGL_RESULT (XGLAPI *xglCreateDynamicViewportStateType)(XGL_DEVICE device, const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_VP_STATE_OBJECT* pState); typedef XGL_RESULT (XGLAPI *xglCreateDynamicRasterStateType)(XGL_DEVICE device, const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_RS_STATE_OBJECT* pState); typedef XGL_RESULT (XGLAPI *xglCreateDynamicColorBlendStateType)(XGL_DEVICE device, const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_CB_STATE_OBJECT* pState); @@ -2034,8 +2130,7 @@ typedef XGL_RESULT (XGLAPI *xglResetCommandBufferType)(XGL_CMD_BUFFER cmdBuffer) typedef XGL_VOID (XGLAPI *xglCmdBindPipelineType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline); typedef XGL_VOID (XGLAPI *xglCmdBindPipelineDeltaType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta); typedef XGL_VOID (XGLAPI *xglCmdBindDynamicStateObjectType)(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state); -typedef XGL_VOID (XGLAPI *xglCmdBindDescriptorSetType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT index, XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT slotOffset); -typedef XGL_VOID (XGLAPI *xglCmdBindDynamicBufferViewType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferView); +typedef XGL_VOID (XGLAPI *xglCmdBindDescriptorSetType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET descriptorSet, const XGL_UINT* pUserData); typedef XGL_VOID (XGLAPI *xglCmdBindVertexBufferType)(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_UINT binding); typedef XGL_VOID (XGLAPI *xglCmdBindIndexBufferType)(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType); typedef XGL_VOID (XGLAPI *xglCmdDrawType)(XGL_CMD_BUFFER cmdBuffer, XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount); @@ -2400,45 +2495,48 @@ XGL_RESULT XGLAPI xglCreateSampler( // Descriptor set functions -XGL_RESULT XGLAPI xglCreateDescriptorSet( - XGL_DEVICE device, - const XGL_DESCRIPTOR_SET_CREATE_INFO* pCreateInfo, - XGL_DESCRIPTOR_SET* pDescriptorSet); - -XGL_VOID XGLAPI xglBeginDescriptorSetUpdate( - XGL_DESCRIPTOR_SET descriptorSet); - -XGL_VOID XGLAPI xglEndDescriptorSetUpdate( - XGL_DESCRIPTOR_SET descriptorSet); - -XGL_VOID XGLAPI xglAttachSamplerDescriptors( - XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT startSlot, - XGL_UINT slotCount, - const XGL_SAMPLER* pSamplers); - -XGL_VOID XGLAPI xglAttachImageViewDescriptors( - XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT startSlot, - XGL_UINT slotCount, - const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews); - -XGL_VOID XGLAPI xglAttachBufferViewDescriptors( - XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT startSlot, - XGL_UINT slotCount, - const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferViews); - -XGL_VOID XGLAPI xglAttachNestedDescriptors( - XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT startSlot, - XGL_UINT slotCount, - const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets); - -XGL_VOID XGLAPI xglClearDescriptorSetSlots( - XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT startSlot, - XGL_UINT slotCount); +XGL_RESULT XGLAPI xglCreateDescriptorSetLayout( + XGL_DEVICE device, + XGL_FLAGS stageFlags, // XGL_SHADER_STAGE_FLAGS + const XGL_UINT* pSetBindPoints, + XGL_DESCRIPTOR_SET_LAYOUT priorSetLayout, + const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pSetLayoutInfoList, + XGL_DESCRIPTOR_SET_LAYOUT* pSetLayout); + +XGL_RESULT XGLAPI xglBeginDescriptorRegionUpdate( + XGL_DEVICE device, + XGL_DESCRIPTOR_UPDATE_MODE updateMode); + +XGL_RESULT XGLAPI xglEndDescriptorRegionUpdate( + XGL_DEVICE device, + XGL_CMD_BUFFER cmd); + +XGL_RESULT XGLAPI xglCreateDescriptorRegion( + XGL_DEVICE device, + XGL_DESCRIPTOR_REGION_USAGE regionUsage, + XGL_UINT maxSets, + const XGL_DESCRIPTOR_REGION_CREATE_INFO* pCreateInfo, + XGL_DESCRIPTOR_REGION* pDescriptorRegion); + +XGL_RESULT XGLAPI xglClearDescriptorRegion( + XGL_DESCRIPTOR_REGION descriptorRegion); + +XGL_RESULT XGLAPI xglAllocDescriptorSets( + XGL_DESCRIPTOR_REGION descriptorRegion, + XGL_DESCRIPTOR_SET_USAGE setUsage, + XGL_UINT count, + const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts, + XGL_DESCRIPTOR_SET* pDescriptorSets, + XGL_UINT* pCount); + +XGL_VOID XGLAPI xglClearDescriptorSets( + XGL_DESCRIPTOR_REGION descriptorRegion, + XGL_UINT count, + const XGL_DESCRIPTOR_SET* pDescriptorSets); + +XGL_VOID XGLAPI xglUpdateDescriptors( + XGL_DESCRIPTOR_SET descriptorSet, + const XGL_VOID* pUpdateChain); // State object functions @@ -2499,14 +2597,8 @@ XGL_VOID XGLAPI xglCmdBindDynamicStateObject( XGL_VOID XGLAPI xglCmdBindDescriptorSet( XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, - XGL_UINT index, XGL_DESCRIPTOR_SET descriptorSet, - XGL_UINT slotOffset); - -XGL_VOID XGLAPI xglCmdBindDynamicBufferView( - XGL_CMD_BUFFER cmdBuffer, - XGL_PIPELINE_BIND_POINT pipelineBindPoint, - const XGL_BUFFER_VIEW_ATTACH_INFO* pBufferView); + const XGL_UINT* pUserData); XGL_VOID XGLAPI xglCmdBindVertexBuffer( XGL_CMD_BUFFER cmdBuffer, diff --git a/include/xglDbg.h b/include/xglDbg.h index 3ea8448f..f9c82fca 100644 --- a/include/xglDbg.h +++ b/include/xglDbg.h @@ -89,6 +89,8 @@ typedef enum _XGL_DBG_OBJECT_TYPE XGL_DBG_OBJECT_BUFFER, XGL_DBG_OBJECT_BUFFER_VIEW, + XGL_DBG_OBJECT_DESCRIPTOR_SET_LAYOUT, + XGL_DBG_OBJECT_DESCRIPTOR_REGION, XGL_DBG_OBJECT_TYPE_BEGIN_RANGE = XGL_DBG_OBJECT_UNKNOWN, XGL_DBG_OBJECT_TYPE_END_RANGE = XGL_DBG_OBJECT_RENDER_PASS, diff --git a/include/xglLayer.h b/include/xglLayer.h index 494d77d2..09537dc1 100644 --- a/include/xglLayer.h +++ b/include/xglLayer.h @@ -82,14 +82,14 @@ typedef struct _XGL_LAYER_DISPATCH_TABLE xglLoadPipelineType LoadPipeline; xglCreatePipelineDeltaType CreatePipelineDelta; xglCreateSamplerType CreateSampler; - xglCreateDescriptorSetType CreateDescriptorSet; - xglBeginDescriptorSetUpdateType BeginDescriptorSetUpdate; - xglEndDescriptorSetUpdateType EndDescriptorSetUpdate; - xglAttachSamplerDescriptorsType AttachSamplerDescriptors; - xglAttachImageViewDescriptorsType AttachImageViewDescriptors; - xglAttachBufferViewDescriptorsType AttachBufferViewDescriptors; - xglAttachNestedDescriptorsType AttachNestedDescriptors; - xglClearDescriptorSetSlotsType ClearDescriptorSetSlots; + xglCreateDescriptorSetLayoutType CreateDescriptorSetLayout; + xglBeginDescriptorRegionUpdateType BeginDescriptorRegionUpdate; + xglEndDescriptorRegionUpdateType EndDescriptorRegionUpdate; + xglCreateDescriptorRegionType CreateDescriptorRegion; + xglClearDescriptorRegionType ClearDescriptorRegion; + xglAllocDescriptorSetsType AllocDescriptorSets; + xglClearDescriptorSetsType ClearDescriptorSets; + xglUpdateDescriptorsType UpdateDescriptors; xglCreateDynamicViewportStateType CreateDynamicViewportState; xglCreateDynamicRasterStateType CreateDynamicRasterState; xglCreateDynamicColorBlendStateType CreateDynamicColorBlendState; @@ -102,7 +102,6 @@ typedef struct _XGL_LAYER_DISPATCH_TABLE xglCmdBindPipelineDeltaType CmdBindPipelineDelta; xglCmdBindDynamicStateObjectType CmdBindDynamicStateObject; xglCmdBindDescriptorSetType CmdBindDescriptorSet; - xglCmdBindDynamicBufferViewType CmdBindDynamicBufferView; xglCmdBindVertexBufferType CmdBindVertexBuffer; xglCmdBindIndexBufferType CmdBindIndexBuffer; xglCmdDrawType CmdDraw; diff --git a/xgl-generate.py b/xgl-generate.py index f36f9a42..a0f79923 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -152,6 +152,17 @@ class LoaderEntrypointsSubcommand(Subcommand): " return res;\n" "}" % (qual, decl, proto.params[0].name, stmt, obj_write_stmt, proto.params[-1].name)) + elif proto.name == "AllocDescriptorSets": + funcs.append("%s%s\n" + "{\n" + " const XGL_LAYER_DISPATCH_TABLE **disp =\n" + " (const XGL_LAYER_DISPATCH_TABLE **) %s;\n" + " uint32_t i;\n" + " XGL_RESULT res = %s;\n" + " for (i = 0; i < *%s; i++)\n" + " *(const XGL_LAYER_DISPATCH_TABLE **) (%s[i]) = *disp;\n" + " return res;\n" + "}" % (qual, decl, proto.params[0].name, stmt, proto.params[-1].name, proto.params[-2].name)) elif proto.name == "GetMultiGpuCompatibility": funcs.append("%s%s\n" "{\n" diff --git a/xgl.py b/xgl.py index 0e410562..84b39ee6 100644 --- a/xgl.py +++ b/xgl.py @@ -200,6 +200,8 @@ core = Extension( "XGL_PIPELINE_DELTA", "XGL_SAMPLER", "XGL_DESCRIPTOR_SET", + "XGL_DESCRIPTOR_SET_LAYOUT", + "XGL_DESCRIPTOR_REGION", "XGL_DYNAMIC_STATE_OBJECT", "XGL_DYNAMIC_VP_STATE_OBJECT", "XGL_DYNAMIC_RS_STATE_OBJECT", @@ -501,45 +503,48 @@ core = Extension( Param("const XGL_SAMPLER_CREATE_INFO*", "pCreateInfo"), Param("XGL_SAMPLER*", "pSampler")]), - Proto("XGL_RESULT", "CreateDescriptorSet", + Proto("XGL_RESULT", "CreateDescriptorSetLayout", [Param("XGL_DEVICE", "device"), - Param("const XGL_DESCRIPTOR_SET_CREATE_INFO*", "pCreateInfo"), - Param("XGL_DESCRIPTOR_SET*", "pDescriptorSet")]), + Param("XGL_FLAGS", "stageFlags"), + Param("const XGL_UINT*", "pSetBindPoints"), + Param("XGL_DESCRIPTOR_SET_LAYOUT", "priorSetLayout"), + Param("const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*", "pSetLayoutInfoList"), + Param("XGL_DESCRIPTOR_SET_LAYOUT*", "pSetLayout")]), - Proto("XGL_VOID", "BeginDescriptorSetUpdate", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet")]), + Proto("XGL_RESULT", "BeginDescriptorRegionUpdate", + [Param("XGL_DEVICE", "device"), + Param("XGL_DESCRIPTOR_UPDATE_MODE", "updateMode")]), - Proto("XGL_VOID", "EndDescriptorSetUpdate", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet")]), + Proto("XGL_RESULT", "EndDescriptorRegionUpdate", + [Param("XGL_DEVICE", "device"), + Param("XGL_CMD_BUFFER", "cmd")]), - Proto("XGL_VOID", "AttachSamplerDescriptors", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "startSlot"), - Param("XGL_UINT", "slotCount"), - Param("const XGL_SAMPLER*", "pSamplers")]), + Proto("XGL_RESULT", "CreateDescriptorRegion", + [Param("XGL_DEVICE", "device"), + Param("XGL_DESCRIPTOR_REGION_USAGE", "regionUsage"), + Param("XGL_UINT", "maxSets"), + Param("const XGL_DESCRIPTOR_REGION_CREATE_INFO*", "pCreateInfo"), + Param("XGL_DESCRIPTOR_REGION*", "pDescriptorRegion")]), - Proto("XGL_VOID", "AttachImageViewDescriptors", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "startSlot"), - Param("XGL_UINT", "slotCount"), - Param("const XGL_IMAGE_VIEW_ATTACH_INFO*", "pImageViews")]), + Proto("XGL_RESULT", "ClearDescriptorRegion", + [Param("XGL_DESCRIPTOR_REGION", "descriptorRegion")]), - Proto("XGL_VOID", "AttachBufferViewDescriptors", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "startSlot"), - Param("XGL_UINT", "slotCount"), - Param("const XGL_BUFFER_VIEW_ATTACH_INFO*", "pBufferViews")]), + Proto("XGL_RESULT", "AllocDescriptorSets", + [Param("XGL_DESCRIPTOR_REGION", "descriptorRegion"), + Param("XGL_DESCRIPTOR_SET_USAGE", "setUsage"), + Param("XGL_UINT", "count"), + Param("const XGL_DESCRIPTOR_SET_LAYOUT*", "pSetLayouts"), + Param("XGL_DESCRIPTOR_SET*", "pDescriptorSets"), + Param("XGL_UINT*", "pCount")]), - Proto("XGL_VOID", "AttachNestedDescriptors", - [Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "startSlot"), - Param("XGL_UINT", "slotCount"), - Param("const XGL_DESCRIPTOR_SET_ATTACH_INFO*", "pNestedDescriptorSets")]), + Proto("XGL_VOID", "ClearDescriptorSets", + [Param("XGL_DESCRIPTOR_REGION", "descriptorRegion"), + Param("XGL_UINT", "count"), + Param("const XGL_DESCRIPTOR_SET*", "pDescriptorSets")]), - Proto("XGL_VOID", "ClearDescriptorSetSlots", + Proto("XGL_VOID", "UpdateDescriptors", [Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "startSlot"), - Param("XGL_UINT", "slotCount")]), + Param("const XGL_VOID*", "pUpdateChain")]), Proto("XGL_RESULT", "CreateDynamicViewportState", [Param("XGL_DEVICE", "device"), @@ -594,14 +599,8 @@ core = Extension( Proto("XGL_VOID", "CmdBindDescriptorSet", [Param("XGL_CMD_BUFFER", "cmdBuffer"), Param("XGL_PIPELINE_BIND_POINT", "pipelineBindPoint"), - Param("XGL_UINT", "index"), Param("XGL_DESCRIPTOR_SET", "descriptorSet"), - Param("XGL_UINT", "slotOffset")]), - - Proto("XGL_VOID", "CmdBindDynamicBufferView", - [Param("XGL_CMD_BUFFER", "cmdBuffer"), - Param("XGL_PIPELINE_BIND_POINT", "pipelineBindPoint"), - Param("const XGL_BUFFER_VIEW_ATTACH_INFO*", "pBufferView")]), + Param("const XGL_UINT*", "pUserData")]), Proto("XGL_VOID", "CmdBindVertexBuffer", [Param("XGL_CMD_BUFFER", "cmdBuffer"), -- 2.34.1