vk: Add initial API support for setting push constants
This doesn't add support for actually uploading them, it just ensures that we have and update the shadow copy.
This commit is contained in:
@@ -47,10 +47,12 @@ anv_cmd_state_init(struct anv_cmd_state *state)
|
|||||||
state->ds_state = NULL;
|
state->ds_state = NULL;
|
||||||
memset(&state->state_vf, 0, sizeof(state->state_vf));
|
memset(&state->state_vf, 0, sizeof(state->state_vf));
|
||||||
memset(&state->descriptors, 0, sizeof(state->descriptors));
|
memset(&state->descriptors, 0, sizeof(state->descriptors));
|
||||||
|
memset(&state->push_constants, 0, sizeof(state->push_constants));
|
||||||
|
|
||||||
state->dirty = 0;
|
state->dirty = 0;
|
||||||
state->vb_dirty = 0;
|
state->vb_dirty = 0;
|
||||||
state->descriptors_dirty = 0;
|
state->descriptors_dirty = 0;
|
||||||
|
state->push_constants_dirty = 0;
|
||||||
state->pipeline = NULL;
|
state->pipeline = NULL;
|
||||||
state->vp_state = NULL;
|
state->vp_state = NULL;
|
||||||
state->rs_state = NULL;
|
state->rs_state = NULL;
|
||||||
@@ -210,12 +212,14 @@ void anv_CmdBindPipeline(
|
|||||||
case VK_PIPELINE_BIND_POINT_COMPUTE:
|
case VK_PIPELINE_BIND_POINT_COMPUTE:
|
||||||
cmd_buffer->state.compute_pipeline = pipeline;
|
cmd_buffer->state.compute_pipeline = pipeline;
|
||||||
cmd_buffer->state.compute_dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY;
|
cmd_buffer->state.compute_dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY;
|
||||||
|
cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_PIPELINE_BIND_POINT_GRAPHICS:
|
case VK_PIPELINE_BIND_POINT_GRAPHICS:
|
||||||
cmd_buffer->state.pipeline = pipeline;
|
cmd_buffer->state.pipeline = pipeline;
|
||||||
cmd_buffer->state.vb_dirty |= pipeline->vb_used;
|
cmd_buffer->state.vb_dirty |= pipeline->vb_used;
|
||||||
cmd_buffer->state.dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY;
|
cmd_buffer->state.dirty |= ANV_CMD_BUFFER_PIPELINE_DIRTY;
|
||||||
|
cmd_buffer->state.push_constants_dirty |= pipeline->active_stages;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -665,7 +669,22 @@ void anv_CmdPushConstants(
|
|||||||
uint32_t length,
|
uint32_t length,
|
||||||
const void* values)
|
const void* values)
|
||||||
{
|
{
|
||||||
stub();
|
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
|
||||||
|
uint32_t stage;
|
||||||
|
|
||||||
|
for_each_bit(stage, stageFlags) {
|
||||||
|
if (cmd_buffer->state.push_constants[stage].data == NULL) {
|
||||||
|
cmd_buffer->state.push_constants[stage].data =
|
||||||
|
anv_device_alloc(cmd_buffer->device,
|
||||||
|
sizeof(struct anv_push_constant_data), 8,
|
||||||
|
VK_SYSTEM_ALLOC_TYPE_INTERNAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(cmd_buffer->state.push_constants[stage].data->client_data + start,
|
||||||
|
values, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd_buffer->state.push_constants_dirty |= stageFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void anv_CmdExecuteCommands(
|
void anv_CmdExecuteCommands(
|
||||||
|
@@ -289,7 +289,7 @@ VkResult anv_GetPhysicalDeviceLimits(
|
|||||||
.maxTexelBufferSize = (1 << 14),
|
.maxTexelBufferSize = (1 << 14),
|
||||||
.maxUniformBufferSize = UINT32_MAX,
|
.maxUniformBufferSize = UINT32_MAX,
|
||||||
.maxStorageBufferSize = UINT32_MAX,
|
.maxStorageBufferSize = UINT32_MAX,
|
||||||
.maxPushConstantsSize = 128,
|
.maxPushConstantsSize = MAX_PUSH_CONSTANTS_SIZE,
|
||||||
.maxMemoryAllocationCount = UINT32_MAX,
|
.maxMemoryAllocationCount = UINT32_MAX,
|
||||||
.bufferImageGranularity = 64, /* A cache line */
|
.bufferImageGranularity = 64, /* A cache line */
|
||||||
.maxBoundDescriptorSets = MAX_SETS,
|
.maxBoundDescriptorSets = MAX_SETS,
|
||||||
|
@@ -642,6 +642,7 @@ anv_descriptor_set_destroy(struct anv_device *device,
|
|||||||
#define MAX_VBS 32
|
#define MAX_VBS 32
|
||||||
#define MAX_SETS 8
|
#define MAX_SETS 8
|
||||||
#define MAX_RTS 8
|
#define MAX_RTS 8
|
||||||
|
#define MAX_PUSH_CONSTANTS_SIZE 128
|
||||||
|
|
||||||
struct anv_pipeline_layout {
|
struct anv_pipeline_layout {
|
||||||
struct {
|
struct {
|
||||||
@@ -684,6 +685,16 @@ struct anv_descriptor_set_binding {
|
|||||||
uint32_t dynamic_offsets[128];
|
uint32_t dynamic_offsets[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct anv_push_constant_data {
|
||||||
|
uint8_t client_data[MAX_PUSH_CONSTANTS_SIZE];
|
||||||
|
uint8_t driver_data[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct anv_push_constants {
|
||||||
|
uint32_t driver_data_size;
|
||||||
|
struct anv_push_constant_data *data;
|
||||||
|
};
|
||||||
|
|
||||||
/** State required while building cmd buffer */
|
/** State required while building cmd buffer */
|
||||||
struct anv_cmd_state {
|
struct anv_cmd_state {
|
||||||
uint32_t current_pipeline;
|
uint32_t current_pipeline;
|
||||||
@@ -691,6 +702,7 @@ struct anv_cmd_state {
|
|||||||
uint32_t dirty;
|
uint32_t dirty;
|
||||||
uint32_t compute_dirty;
|
uint32_t compute_dirty;
|
||||||
uint32_t descriptors_dirty;
|
uint32_t descriptors_dirty;
|
||||||
|
uint32_t push_constants_dirty;
|
||||||
uint32_t scratch_size;
|
uint32_t scratch_size;
|
||||||
struct anv_pipeline * pipeline;
|
struct anv_pipeline * pipeline;
|
||||||
struct anv_pipeline * compute_pipeline;
|
struct anv_pipeline * compute_pipeline;
|
||||||
@@ -704,6 +716,7 @@ struct anv_cmd_state {
|
|||||||
uint32_t state_vf[GEN8_3DSTATE_VF_length];
|
uint32_t state_vf[GEN8_3DSTATE_VF_length];
|
||||||
struct anv_vertex_binding vertex_bindings[MAX_VBS];
|
struct anv_vertex_binding vertex_bindings[MAX_VBS];
|
||||||
struct anv_descriptor_set_binding descriptors[MAX_SETS];
|
struct anv_descriptor_set_binding descriptors[MAX_SETS];
|
||||||
|
struct anv_push_constants push_constants[VK_SHADER_STAGE_NUM];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct anv_buffer * index_buffer;
|
struct anv_buffer * index_buffer;
|
||||||
|
Reference in New Issue
Block a user