From 263045afbc731fe669b43013a32c6dfa457e46ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 10 Sep 2012 05:43:12 +0200 Subject: [PATCH] r600g: add support for geometry shader samplers and constant buffers Reviewed-by: Jerome Glisse --- src/gallium/drivers/r600/evergreen_state.c | 20 ++++++++++++++++ src/gallium/drivers/r600/evergreend.h | 2 ++ src/gallium/drivers/r600/r600_pipe.h | 2 +- src/gallium/drivers/r600/r600_state.c | 27 ++++++++++++++++++++++ src/gallium/drivers/r600/r600d.h | 2 ++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index a29b0b4a472..c0615767be2 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2027,6 +2027,13 @@ static void evergreen_emit_vs_constant_buffers(struct r600_context *rctx, struct R_028980_ALU_CONST_CACHE_VS_0); } +static void evergreen_emit_gs_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) +{ + evergreen_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_GEOMETRY], 336, + R_0281C0_ALU_CONST_BUFFER_SIZE_GS_0, + R_0289C0_ALU_CONST_CACHE_GS_0); +} + static void evergreen_emit_ps_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { evergreen_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT], 0, @@ -2069,6 +2076,11 @@ static void evergreen_emit_vs_sampler_views(struct r600_context *rctx, struct r6 evergreen_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views, 176 + R600_MAX_CONST_BUFFERS); } +static void evergreen_emit_gs_sampler_views(struct r600_context *rctx, struct r600_atom *atom) +{ + evergreen_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].views, 336 + R600_MAX_CONST_BUFFERS); +} + static void evergreen_emit_ps_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { evergreen_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views, R600_MAX_CONST_BUFFERS); @@ -2107,6 +2119,11 @@ static void evergreen_emit_vs_sampler_states(struct r600_context *rctx, struct r evergreen_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_VERTEX], 18, R_00A414_TD_VS_SAMPLER0_BORDER_INDEX); } +static void evergreen_emit_gs_sampler_states(struct r600_context *rctx, struct r600_atom *atom) +{ + evergreen_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY], 36, R_00A428_TD_GS_SAMPLER0_BORDER_INDEX); +} + static void evergreen_emit_ps_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { evergreen_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT], 0, R_00A400_TD_PS_SAMPLER0_BORDER_INDEX); @@ -2148,16 +2165,19 @@ void evergreen_init_state_functions(struct r600_context *rctx) /* shader const */ r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX].atom, id++, evergreen_emit_vs_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_GEOMETRY].atom, id++, evergreen_emit_gs_constant_buffers, 0); r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT].atom, id++, evergreen_emit_ps_constant_buffers, 0); /* shader program */ r600_init_atom(rctx, &rctx->cs_shader_state.atom, id++, evergreen_emit_cs_shader, 0); /* sampler */ r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].states.atom, id++, evergreen_emit_vs_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].states.atom, id++, evergreen_emit_gs_sampler_states, 0); r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].states.atom, id++, evergreen_emit_ps_sampler_states, 0); /* resources */ r600_init_atom(rctx, &rctx->vertex_buffer_state.atom, id++, evergreen_fs_emit_vertex_buffers, 0); r600_init_atom(rctx, &rctx->cs_vertex_buffer_state.atom, id++, evergreen_cs_emit_vertex_buffers, 0); r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views.atom, id++, evergreen_emit_vs_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].views.atom, id++, evergreen_emit_gs_sampler_views, 0); r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views.atom, id++, evergreen_emit_ps_sampler_views, 0); if (rctx->chip_class == EVERGREEN) { diff --git a/src/gallium/drivers/r600/evergreend.h b/src/gallium/drivers/r600/evergreend.h index 18e1eb7bc66..cb891997d30 100644 --- a/src/gallium/drivers/r600/evergreend.h +++ b/src/gallium/drivers/r600/evergreend.h @@ -1646,6 +1646,7 @@ #define R_028144_ALU_CONST_BUFFER_SIZE_PS_1 0x00028144 #define R_028180_ALU_CONST_BUFFER_SIZE_VS_0 0x00028180 #define R_028184_ALU_CONST_BUFFER_SIZE_VS_1 0x00028184 +#define R_0281C0_ALU_CONST_BUFFER_SIZE_GS_0 0x000281C0 #define R_028200_PA_SC_WINDOW_OFFSET 0x00028200 #define R_02820C_PA_SC_CLIPRECT_RULE 0x0002820C #define R_028210_PA_SC_CLIPRECT_0_TL 0x00028210 @@ -1834,6 +1835,7 @@ #define R_028944_ALU_CONST_CACHE_PS_1 0x00028944 #define R_028980_ALU_CONST_CACHE_VS_0 0x00028980 #define R_028984_ALU_CONST_CACHE_VS_1 0x00028984 +#define R_0289C0_ALU_CONST_CACHE_GS_0 0x000289C0 #define R_028A04_PA_SU_POINT_MINMAX 0x00028A04 #define S_028A04_MIN_SIZE(x) (((x) & 0xFFFF) << 0) #define G_028A04_MIN_SIZE(x) (((x) >> 0) & 0xFFFF) diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index b101db637b9..7edcde6d864 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -35,7 +35,7 @@ #include "r600_resource.h" #include "evergreen_compute.h" -#define R600_MAX_ATOM 17 +#define R600_MAX_ATOM 20 #define R600_MAX_CONST_BUFFERS 2 #define R600_MAX_CONST_BUFFER_SIZE 4096 diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index 05271e20132..abe886c5e2a 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1879,6 +1879,13 @@ static void r600_emit_vs_constant_buffers(struct r600_context *rctx, struct r600 R_028980_ALU_CONST_CACHE_VS_0); } +static void r600_emit_gs_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) +{ + r600_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_GEOMETRY], 336, + R_0281C0_ALU_CONST_BUFFER_SIZE_GS_0, + R_0289C0_ALU_CONST_CACHE_GS_0); +} + static void r600_emit_ps_constant_buffers(struct r600_context *rctx, struct r600_atom *atom) { r600_emit_constant_buffers(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT], 0, @@ -1916,11 +1923,23 @@ static void r600_emit_sampler_views(struct r600_context *rctx, state->dirty_mask = 0; } +/* Resource IDs: + * PS: 0 .. +160 + * VS: 160 .. +160 + * FS: 320 .. +16 + * GS: 336 .. +160 + */ + static void r600_emit_vs_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { r600_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views, 160 + R600_MAX_CONST_BUFFERS); } +static void r600_emit_gs_sampler_views(struct r600_context *rctx, struct r600_atom *atom) +{ + r600_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].views, 336 + R600_MAX_CONST_BUFFERS); +} + static void r600_emit_ps_sampler_views(struct r600_context *rctx, struct r600_atom *atom) { r600_emit_sampler_views(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views, R600_MAX_CONST_BUFFERS); @@ -1980,6 +1999,11 @@ static void r600_emit_vs_sampler_states(struct r600_context *rctx, struct r600_a r600_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_VERTEX], 18, R_00A600_TD_VS_SAMPLER0_BORDER_RED); } +static void r600_emit_gs_sampler_states(struct r600_context *rctx, struct r600_atom *atom) +{ + r600_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY], 36, R_00A800_TD_GS_SAMPLER0_BORDER_RED); +} + static void r600_emit_ps_sampler_states(struct r600_context *rctx, struct r600_atom *atom) { r600_emit_sampler_states(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT], 0, R_00A400_TD_PS_SAMPLER0_BORDER_RED); @@ -2025,15 +2049,18 @@ void r600_init_state_functions(struct r600_context *rctx) /* shader const */ r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_VERTEX].atom, id++, r600_emit_vs_constant_buffers, 0); + r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_GEOMETRY].atom, id++, r600_emit_gs_constant_buffers, 0); r600_init_atom(rctx, &rctx->constbuf_state[PIPE_SHADER_FRAGMENT].atom, id++, r600_emit_ps_constant_buffers, 0); /* sampler must be emited before TA_CNTL_AUX otherwise DISABLE_CUBE_WRAP change * does not take effect (TA_CNTL_AUX emited by r600_emit_seamless_cube_map) */ r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].states.atom, id++, r600_emit_vs_sampler_states, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].states.atom, id++, r600_emit_gs_sampler_states, 0); r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].states.atom, id++, r600_emit_ps_sampler_states, 0); /* resource */ r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_VERTEX].views.atom, id++, r600_emit_vs_sampler_views, 0); + r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_GEOMETRY].views.atom, id++, r600_emit_gs_sampler_views, 0); r600_init_atom(rctx, &rctx->samplers[PIPE_SHADER_FRAGMENT].views.atom, id++, r600_emit_ps_sampler_views, 0); r600_init_atom(rctx, &rctx->vertex_buffer_state.atom, id++, r600_emit_vertex_buffers, 0); diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h index 4bd77161ca9..0ec0586602d 100644 --- a/src/gallium/drivers/r600/r600d.h +++ b/src/gallium/drivers/r600/r600d.h @@ -3596,10 +3596,12 @@ #define R_028144_ALU_CONST_BUFFER_SIZE_PS_1 0x00028144 #define R_028180_ALU_CONST_BUFFER_SIZE_VS_0 0x00028180 #define R_028184_ALU_CONST_BUFFER_SIZE_VS_1 0x00028184 +#define R_0281C0_ALU_CONST_BUFFER_SIZE_GS_0 0x000281C0 #define R_028940_ALU_CONST_CACHE_PS_0 0x00028940 #define R_028944_ALU_CONST_CACHE_PS_1 0x00028944 #define R_028980_ALU_CONST_CACHE_VS_0 0x00028980 #define R_028984_ALU_CONST_CACHE_VS_1 0x00028984 +#define R_0289C0_ALU_CONST_CACHE_GS_0 0x000289C0 #define R_03CFF0_SQ_VTX_BASE_VTX_LOC 0x03CFF0 #define R_03CFF4_SQ_VTX_START_INST_LOC 0x03CFF4 -- 2.30.2