zink: implement ARB_instanced_arrays
this is just a simple case of connecting up the vertex state to the pipeline state Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6270>
This commit is contained in:

committed by
Marge Bot

parent
0051551701
commit
818bd61099
@@ -107,7 +107,7 @@ GL 3.3, GLSL 3.30 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft
|
||||
GL_ARB_texture_rgb10_a2ui DONE (freedreno, swr, zink, panfrost)
|
||||
GL_ARB_texture_swizzle DONE (freedreno, swr, v3d, zink, panfrost)
|
||||
GL_ARB_timer_query DONE (freedreno, swr)
|
||||
GL_ARB_instanced_arrays DONE (freedreno, swr, v3d, panfrost)
|
||||
GL_ARB_instanced_arrays DONE (freedreno, swr, v3d, panfrost, zink)
|
||||
GL_ARB_vertex_type_2_10_10_10_rev DONE (freedreno, swr, v3d, panfrost)
|
||||
|
||||
|
||||
|
@@ -46,6 +46,14 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
||||
vertex_input_state.pVertexAttributeDescriptions = state->element_state->attribs;
|
||||
vertex_input_state.vertexAttributeDescriptionCount = state->element_state->num_attribs;
|
||||
|
||||
VkPipelineVertexInputDivisorStateCreateInfoEXT vdiv_state = {};
|
||||
if (state->divisors_present) {
|
||||
vertex_input_state.pNext = &vdiv_state;
|
||||
vdiv_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT;
|
||||
vdiv_state.vertexBindingDivisorCount = state->divisors_present;
|
||||
vdiv_state.pVertexBindingDivisors = state->divisors;
|
||||
}
|
||||
|
||||
VkPipelineInputAssemblyStateCreateInfo primitive_state = {};
|
||||
primitive_state.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
primitive_state.topology = primitive_topology;
|
||||
|
@@ -41,6 +41,8 @@ struct zink_gfx_pipeline_state {
|
||||
|
||||
struct zink_vertex_elements_hw_state *element_state;
|
||||
VkVertexInputBindingDescription bindings[PIPE_MAX_ATTRIBS]; // combination of element_state and stride
|
||||
VkVertexInputBindingDivisorDescriptionEXT divisors[PIPE_MAX_ATTRIBS];
|
||||
uint8_t divisors_present;
|
||||
|
||||
uint32_t num_attachments;
|
||||
struct zink_blend_state *blend_state;
|
||||
|
@@ -98,6 +98,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_TGSI_TEXCOORD:
|
||||
return 1;
|
||||
|
||||
case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
|
||||
return screen->have_EXT_vertex_attribute_divisor;
|
||||
|
||||
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
|
||||
if (!screen->feats.dualSrcBlend)
|
||||
return 0;
|
||||
|
@@ -48,7 +48,6 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
|
||||
int num_bindings = 0;
|
||||
for (i = 0; i < num_elements; ++i) {
|
||||
const struct pipe_vertex_element *elem = elements + i;
|
||||
assert(!elem->instance_divisor);
|
||||
|
||||
int binding = elem->vertex_buffer_index;
|
||||
if (buffer_map[binding] < 0) {
|
||||
@@ -59,7 +58,11 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
|
||||
|
||||
|
||||
ves->bindings[binding].binding = binding;
|
||||
ves->bindings[binding].inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
ves->bindings[binding].inputRate = elem->instance_divisor ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
|
||||
assert(!elem->instance_divisor || zink_screen(pctx->screen)->have_EXT_vertex_attribute_divisor);
|
||||
ves->divisor[binding] = elem->instance_divisor;
|
||||
assert(elem->instance_divisor <= screen->max_vertex_attrib_divisor);
|
||||
|
||||
ves->hw_state.attribs[i].binding = binding;
|
||||
ves->hw_state.attribs[i].location = i; // TODO: unsure
|
||||
@@ -82,12 +85,18 @@ zink_bind_vertex_elements_state(struct pipe_context *pctx,
|
||||
struct zink_gfx_pipeline_state *state = &ctx->gfx_pipeline_state;
|
||||
ctx->element_state = cso;
|
||||
state->hash = 0;
|
||||
state->divisors_present = 0;
|
||||
if (cso) {
|
||||
state->element_state = &ctx->element_state->hw_state;
|
||||
struct zink_vertex_elements_state *ves = cso;
|
||||
for (int i = 0; i < state->element_state->num_bindings; ++i) {
|
||||
state->bindings[i].binding = ves->bindings[i].binding;
|
||||
state->bindings[i].inputRate = ves->bindings[i].inputRate;
|
||||
if (ves->divisor[i]) {
|
||||
state->divisors[state->divisors_present].divisor = ves->divisor[i];
|
||||
state->divisors[state->divisors_present].binding = state->bindings[i].binding;
|
||||
state->divisors_present++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
state->element_state = NULL;
|
||||
|
@@ -38,6 +38,7 @@ struct zink_vertex_elements_state {
|
||||
uint32_t binding;
|
||||
VkVertexInputRate inputRate;
|
||||
} bindings[PIPE_MAX_ATTRIBS];
|
||||
uint32_t divisor[PIPE_MAX_ATTRIBS];
|
||||
uint8_t binding_map[PIPE_MAX_ATTRIBS];
|
||||
struct zink_vertex_elements_hw_state hw_state;
|
||||
};
|
||||
|
Reference in New Issue
Block a user