Add push constants
Added functions for adding push constants to pipeline Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode@xyz>
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#define MAX_VERTEX_BINDINGS_COUNT (32U)
|
#define MAX_VERTEX_BINDINGS_COUNT (32U)
|
||||||
#define MAX_SHADER_ATTRIBUTES_COUNT (32U)
|
#define MAX_SHADER_ATTRIBUTES_COUNT (32U)
|
||||||
#define MAX_DYNAMIC_STATES_COUNT (32U)
|
#define MAX_DYNAMIC_STATES_COUNT (32U)
|
||||||
|
#define MAX_PUSH_CONSTANTS_COUNT (32U)
|
||||||
|
|
||||||
#define DESCRIPTOR_MAX_SETS (32U)
|
#define DESCRIPTOR_MAX_SETS (32U)
|
||||||
#define DESCRIPTOR_TYPE_ID_MAX_ENUM (21U)
|
#define DESCRIPTOR_TYPE_ID_MAX_ENUM (21U)
|
||||||
@@ -126,6 +127,12 @@ struct required_dynamic_states_t {
|
|||||||
VkDynamicState dynamic_states[MAX_DYNAMIC_STATES_COUNT];
|
VkDynamicState dynamic_states[MAX_DYNAMIC_STATES_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct push_constant_ranges_t
|
||||||
|
{
|
||||||
|
size_t push_constant_ranges_count;
|
||||||
|
VkPushConstantRange push_constant_ranges[MAX_PUSH_CONSTANTS_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
struct pipeline_infos_t
|
struct pipeline_infos_t
|
||||||
{
|
{
|
||||||
size_t pipeline_create_infos_count;
|
size_t pipeline_create_infos_count;
|
||||||
@@ -159,6 +166,7 @@ struct pipeline_t
|
|||||||
VkVertexInputAttributeDescription shader_attributes[MAX_SHADER_ATTRIBUTES_COUNT];
|
VkVertexInputAttributeDescription shader_attributes[MAX_SHADER_ATTRIBUTES_COUNT];
|
||||||
size_t dynamic_states_count;
|
size_t dynamic_states_count;
|
||||||
VkDynamicState dynamic_states[MAX_DYNAMIC_STATES_COUNT];
|
VkDynamicState dynamic_states[MAX_DYNAMIC_STATES_COUNT];
|
||||||
|
struct push_constant_ranges_t push_constant_ranges;
|
||||||
struct required_dynamic_states_t required_dynamic_states;
|
struct required_dynamic_states_t required_dynamic_states;
|
||||||
struct descriptor_set_handle_t* descriptor_sets;
|
struct descriptor_set_handle_t* descriptor_sets;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -205,8 +205,8 @@ rse_err_t pipeline_add_descriptor_sets(struct graphics_context_t* context,
|
|||||||
create_info.flags = 0U;
|
create_info.flags = 0U;
|
||||||
create_info.setLayoutCount = 1; // FIXME: Make sure we can enable more than one layout
|
create_info.setLayoutCount = 1; // FIXME: Make sure we can enable more than one layout
|
||||||
create_info.pSetLayouts = &context->descriptor_data.set_layouts[descriptor_set_id];
|
create_info.pSetLayouts = &context->descriptor_data.set_layouts[descriptor_set_id];
|
||||||
create_info.pushConstantRangeCount = 0U;
|
create_info.pushConstantRangeCount = pipeline->push_constant_ranges.push_constant_ranges_count;
|
||||||
create_info.pPushConstantRanges = NULL;
|
create_info.pPushConstantRanges = pipeline->push_constant_ranges.push_constant_ranges;
|
||||||
|
|
||||||
if (VK_SUCCESS !=
|
if (VK_SUCCESS !=
|
||||||
vkCreatePipelineLayout(context->vulkan_handles.device, &create_info, NULL, &pipeline->pipeline_layout)) {
|
vkCreatePipelineLayout(context->vulkan_handles.device, &create_info, NULL, &pipeline->pipeline_layout)) {
|
||||||
@@ -341,6 +341,23 @@ rse_err_t pipeline_add_vertex_input_attribute(struct pipeline_t* pipeline,
|
|||||||
return RSE_ERROR_NO_ERROR;
|
return RSE_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rse_err_t pipeline_addd_push_constants(struct pipeline_t* pipeline,
|
||||||
|
VkShaderStageFlagBits shader_stage,
|
||||||
|
uint32_t offset,
|
||||||
|
uint32_t size)
|
||||||
|
{
|
||||||
|
pipeline->push_constant_ranges.push_constant_ranges[pipeline->push_constant_ranges.push_constant_ranges_count]
|
||||||
|
.stageFlags = shader_stage;
|
||||||
|
pipeline->push_constant_ranges.push_constant_ranges[pipeline->push_constant_ranges.push_constant_ranges_count]
|
||||||
|
.offset = offset;
|
||||||
|
pipeline->push_constant_ranges.push_constant_ranges[pipeline->push_constant_ranges.push_constant_ranges_count]
|
||||||
|
.size = size;
|
||||||
|
|
||||||
|
pipeline->push_constant_ranges.push_constant_ranges_count++;
|
||||||
|
|
||||||
|
return RSE_ERROR_NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
rse_err_t pipelines_build(struct graphics_context_t* context, struct pipeline_infos_t* pipelines_infos_list)
|
rse_err_t pipelines_build(struct graphics_context_t* context, struct pipeline_infos_t* pipelines_infos_list)
|
||||||
{
|
{
|
||||||
assert(NULL != context);
|
assert(NULL != context);
|
||||||
|
|||||||
Reference in New Issue
Block a user