diff options
author | Dave Airlie <[email protected]> | 2019-06-26 15:56:32 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-07-07 16:24:09 +1000 |
commit | d8fb66a3e1ffae8e4ef4a31ee961f74d44486a19 (patch) | |
tree | 5966dbdf1fe56fe14283146fdd9512e1eb683c65 /src/gallium/auxiliary | |
parent | b5ac381d8f66fbf2aef92772879ac906ce9d68b2 (diff) |
draw: add shader buffer interfaces.
This adds the interface to add mapped shader buffers,
and sets up the jit linkage for them.
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_context.c | 26 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_context.h | 7 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_private.h | 8 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c | 17 |
4 files changed, 57 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index f8c69585e6a..74436f98016 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -464,6 +464,32 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, } } +void +draw_set_mapped_shader_buffer(struct draw_context *draw, + enum pipe_shader_type shader_type, + unsigned slot, + const void *buffer, + unsigned size ) +{ + debug_assert(shader_type == PIPE_SHADER_VERTEX || + shader_type == PIPE_SHADER_GEOMETRY); + debug_assert(slot < PIPE_MAX_SHADER_BUFFERS); + + draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE); + + switch (shader_type) { + case PIPE_SHADER_VERTEX: + draw->pt.user.vs_ssbos[slot] = buffer; + draw->pt.user.vs_ssbos_size[slot] = size; + break; + case PIPE_SHADER_GEOMETRY: + draw->pt.user.gs_ssbos[slot] = buffer; + draw->pt.user.gs_ssbos_size[slot] = size; + break; + default: + assert(0 && "invalid shader type in draw_set_mapped_shader_buffer"); + } +} /** * Tells the draw module to draw points with triangles if their size diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index d8a1470e901..868d0195a02 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -255,6 +255,13 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, unsigned size); void +draw_set_mapped_shader_buffer(struct draw_context *draw, + enum pipe_shader_type shader_type, + unsigned slot, + const void *buffer, + unsigned size); + +void draw_set_mapped_so_targets(struct draw_context *draw, int num_targets, struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 06ad7372a74..0b236912bef 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -205,7 +205,13 @@ struct draw_context unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS]; unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS]; - + + /** shader buffers (for vertex/geometry shader) */ + const void *vs_ssbos[PIPE_MAX_SHADER_BUFFERS]; + unsigned vs_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; + const void *gs_ssbos[PIPE_MAX_SHADER_BUFFERS]; + unsigned gs_ssbos_size[PIPE_MAX_SHADER_BUFFERS]; + /* pointer to planes */ float (*planes)[DRAW_TOTAL_CLIP_PLANES][4]; } user; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 9f4f887dff0..b96a5c99315 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -297,6 +297,15 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) llvm->jit_context.vs_constants[i] = fake_const_buf; } } + for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_ssbos); ++i) { + int num_ssbos = draw->pt.user.vs_ssbos_size[i]; + llvm->jit_context.vs_ssbos[i] = draw->pt.user.vs_ssbos[i]; + llvm->jit_context.num_vs_ssbos[i] = num_ssbos; + if (num_ssbos == 0) { + llvm->jit_context.vs_ssbos[i] = (const uint32_t *)fake_const_buf; + } + } + for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) { int num_consts = draw->pt.user.gs_constants_size[i] / (sizeof(float) * 4); @@ -306,6 +315,14 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) llvm->gs_jit_context.constants[i] = fake_const_buf; } } + for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.ssbos); ++i) { + int num_ssbos = draw->pt.user.gs_ssbos_size[i]; + llvm->gs_jit_context.ssbos[i] = draw->pt.user.gs_ssbos[i]; + llvm->gs_jit_context.num_ssbos[i] = num_ssbos; + if (num_ssbos == 0) { + llvm->gs_jit_context.ssbos[i] = (const uint32_t *)fake_const_buf; + } + } llvm->jit_context.planes = (float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0]; |