[Mesa-dev] [Mesa-stable] [PATCH 07/19] svga: update shader code for GBS
Ian Romanick
idr at freedesktop.org
Wed Feb 19 11:07:54 PST 2014
This patch didn't apply to the 10.1 branch. I've picked most things to
the 10.1 branch except this series. Could you put a branch up somewhere
and send me a pull request? I'm sure you'd like to have these in the
release, and I don't want to mess them up. :)
2e0c90847f16a9cf2a40436beacb65c65535fa4a svga: split / update svga3d header files
024711385ec5333976b124d33a030c30f1345ed1 svga: update dumping code with new GBS commands, etc
d993ada50cf2f112bfff2bd7fbb5a6c25ca00306 svga: update svga_winsys interface for GBS
823fbfdca7165ac11eab2a7e168960f5874ebdc3 svga: add new GBS commands
31dfefc47f9f12c49fd3cfb27ba4fe384cb60380 svga: add svga_have_gb_objects/dma() functions
2f1fc8db108eb771414aa5440d4c439f63f4e7c1 svga: update constant buffer code for GBS
f84c830b144fd4d53f862fc6ad05541e5bf60a3b svga: update shader code for GBS
c1e60a61e8ca3bdac0530ad1aeb3c751f273b73d svga: add helpers for tracking rendering to textures
d0c22a6d53a9cce2d40006f3d4d7dd7e2f63aca9 svga: track which textures are rendered to
f8bbd8261d297be11f1f2eaf768c2a8ace0cb69d svga: adjust adjustment for point coordinates
6476bcbc5005b76e1494a201f92f3c76bd8e9727 svga: remove a couple unneeded assertions
e0a6fb09bdfde40253b924b6c9d1fdf3f16fed21 svga: add new helper functions for GBS buffers
72b0e959fc38cf4f01d8aaeabe7336cc88588f90 svga: update buffer code for GBS
3d1fd6df5315cfa4b9c8b1332f5078a89abc3ed8 svga: update texture code for GBS
c9e9b1862b472b2671b8d3b339f9f7624a272073 pipebuffer, winsys: Add a size match parameter to the cached buffer manager
8af358d8bc9f7563cd76313b16d7b149197a4b2c gallium/pipebuffer: Add a cache buffer manager bypass mask
59e7c596215155b556ba8cf06233b621b88f49c6 gallium/util: Add flush/map debug utility code
fe6a854477c2ed30c37c200668a4dc86512120f7 svga/winsys: implement GBS support
141e39a8936a7b19fd857a35ea2d200daf1777c7 svga/winsys: Propagate surface shared information to the winsys
e4a5a9fd2fdd5b5ae8b85ac743a228f409a21a70 gallium/pipebuffer: change pb_cache_manager_create() size_factor to float
On 02/13/2014 05:20 PM, Brian Paul wrote:
> Reviewed-by: Thomas Hellstrom <thellstrom at vmware.com>
> Cc: "10.1" <mesa-stable at lists.freedesktop.org>
> ---
> src/gallium/drivers/svga/svga_context.c | 4 +++
> src/gallium/drivers/svga/svga_context.h | 2 ++
> src/gallium/drivers/svga/svga_draw.c | 14 ++++++++
> src/gallium/drivers/svga/svga_shader.c | 21 ++++++++++-
> src/gallium/drivers/svga/svga_state.h | 4 +++
> src/gallium/drivers/svga/svga_state_fs.c | 58 ++++++++++++++++++++++++------
> src/gallium/drivers/svga/svga_state_vs.c | 56 ++++++++++++++++++++++++-----
> src/gallium/drivers/svga/svga_tgsi.h | 3 ++
> 8 files changed, 142 insertions(+), 20 deletions(-)
>
> diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
> index de769ca..4da9a65 100644
> --- a/src/gallium/drivers/svga/svga_context.c
> +++ b/src/gallium/drivers/svga/svga_context.c
> @@ -197,6 +197,10 @@ void svga_context_flush( struct svga_context *svga,
> */
> svga->rebind.rendertargets = TRUE;
> svga->rebind.texture_samplers = TRUE;
> + if (svga_have_gb_objects(svga)) {
> + svga->rebind.vs = TRUE;
> + svga->rebind.fs = TRUE;
> + }
>
> if (SVGA_DEBUG & DEBUG_SYNC) {
> if (fence)
> diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
> index 71a8eea..0daab0b 100644
> --- a/src/gallium/drivers/svga/svga_context.h
> +++ b/src/gallium/drivers/svga/svga_context.h
> @@ -374,6 +374,8 @@ struct svga_context
> struct {
> unsigned rendertargets:1;
> unsigned texture_samplers:1;
> + unsigned vs:1;
> + unsigned fs:1;
> } rebind;
>
> struct svga_hwtnl *hwtnl;
> diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
> index 80dbc35..fa0cac4 100644
> --- a/src/gallium/drivers/svga/svga_draw.c
> +++ b/src/gallium/drivers/svga/svga_draw.c
> @@ -213,6 +213,20 @@ svga_hwtnl_flush(struct svga_hwtnl *hwtnl)
> }
> }
>
> + if (svga->rebind.vs) {
> + ret = svga_reemit_vs_bindings(svga);
> + if (ret != PIPE_OK) {
> + return ret;
> + }
> + }
> +
> + if (svga->rebind.fs) {
> + ret = svga_reemit_fs_bindings(svga);
> + if (ret != PIPE_OK) {
> + return ret;
> + }
> + }
> +
> SVGA_DBG(DEBUG_DMA, "draw to sid %p, %d prims\n",
> svga->curr.framebuffer.cbufs[0] ?
> svga_surface(svga->curr.framebuffer.cbufs[0])->handle : NULL,
> diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
> index 88877b2..6b6b441 100644
> --- a/src/gallium/drivers/svga/svga_shader.c
> +++ b/src/gallium/drivers/svga/svga_shader.c
> @@ -43,7 +43,17 @@ svga_define_shader(struct svga_context *svga,
> {
> unsigned codeLen = variant->nr_tokens * sizeof(variant->tokens[0]);
>
> - {
> + if (svga_have_gb_objects(svga)) {
> + struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
> +
> + variant->gb_shader = sws->shader_create(sws, type,
> + variant->tokens, codeLen);
> + if (!variant->gb_shader)
> + return PIPE_ERROR_OUT_OF_MEMORY;
> +
> + return PIPE_OK;
> + }
> + else {
> enum pipe_error ret;
>
> /* Allocate an integer ID for the shader */
> @@ -79,6 +89,14 @@ svga_destroy_shader_variant(struct svga_context *svga,
> {
> enum pipe_error ret = PIPE_OK;
>
> + if (svga_have_gb_objects(svga)) {
> + struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
> +
> + sws->shader_destroy(sws, variant->gb_shader);
> + variant->gb_shader = NULL;
> + goto end;
> + }
> +
> /* first try */
> if (variant->id != UTIL_BITMASK_INVALID_INDEX) {
> ret = SVGA3D_DestroyShader(svga->swc, variant->id, type);
> @@ -94,6 +112,7 @@ svga_destroy_shader_variant(struct svga_context *svga,
> util_bitmask_clear(svga->shader_id_bm, variant->id);
> }
>
> +end:
> FREE((unsigned *)variant->tokens);
> FREE(variant);
>
> diff --git a/src/gallium/drivers/svga/svga_state.h b/src/gallium/drivers/svga/svga_state.h
> index 7051263..3325626 100644
> --- a/src/gallium/drivers/svga/svga_state.h
> +++ b/src/gallium/drivers/svga/svga_state.h
> @@ -95,4 +95,8 @@ enum pipe_error svga_reemit_framebuffer_bindings( struct svga_context *svga );
>
> enum pipe_error svga_reemit_tss_bindings( struct svga_context *svga );
>
> +enum pipe_error svga_reemit_vs_bindings(struct svga_context *svga);
> +
> +enum pipe_error svga_reemit_fs_bindings(struct svga_context *svga);
> +
> #endif
> diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
> index 7119a19..dde739c 100644
> --- a/src/gallium/drivers/svga/svga_state_fs.c
> +++ b/src/gallium/drivers/svga/svga_state_fs.c
> @@ -321,13 +321,36 @@ make_fs_key(const struct svga_context *svga,
> }
>
>
> +/**
> + * svga_reemit_fs_bindings - Reemit the fragment shader bindings
> + */
> +enum pipe_error
> +svga_reemit_fs_bindings(struct svga_context *svga)
> +{
> + enum pipe_error ret;
> +
> + assert(svga->rebind.fs);
> + assert(svga_have_gb_objects(svga));
> +
> + if (!svga->state.hw_draw.fs)
> + return PIPE_OK;
> +
> + ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_PS,
> + svga->state.hw_draw.fs->gb_shader);
> + if (ret != PIPE_OK)
> + return ret;
> +
> + svga->rebind.fs = FALSE;
> + return PIPE_OK;
> +}
> +
> +
> +
> static enum pipe_error
> emit_hw_fs(struct svga_context *svga, unsigned dirty)
> {
> struct svga_shader_variant *variant = NULL;
> - unsigned id = SVGA3D_INVALID_ID;
> enum pipe_error ret = PIPE_OK;
> -
> struct svga_fragment_shader *fs = svga->curr.fs;
> struct svga_fs_compile_key key;
>
> @@ -349,17 +372,30 @@ emit_hw_fs(struct svga_context *svga, unsigned dirty)
> return ret;
> }
>
> - assert (variant);
> - id = variant->id;
> -
> - assert(id != SVGA3D_INVALID_ID);
> + assert(variant);
>
> if (variant != svga->state.hw_draw.fs) {
> - ret = SVGA3D_SetShader(svga->swc,
> - SVGA3D_SHADERTYPE_PS,
> - id );
> - if (ret != PIPE_OK)
> - return ret;
> + if (svga_have_gb_objects(svga)) {
> + /*
> + * Bind is necessary here only because pipebuffer_fenced may move
> + * the shader contents around....
> + */
> + ret = SVGA3D_BindGBShader(svga->swc, variant->gb_shader);
> + if (ret != PIPE_OK)
> + return ret;
> +
> + ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_PS,
> + variant->gb_shader);
> + if (ret != PIPE_OK)
> + return ret;
> +
> + svga->rebind.fs = FALSE;
> + }
> + else {
> + ret = SVGA3D_SetShader(svga->swc, SVGA3D_SHADERTYPE_PS, variant->id);
> + if (ret != PIPE_OK)
> + return ret;
> + }
>
> svga->dirty |= SVGA_NEW_FS_VARIANT;
> svga->state.hw_draw.fs = variant;
> diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
> index aaef17e..2f130aec 100644
> --- a/src/gallium/drivers/svga/svga_state_vs.c
> +++ b/src/gallium/drivers/svga/svga_state_vs.c
> @@ -162,12 +162,32 @@ make_vs_key(struct svga_context *svga, struct svga_vs_compile_key *key)
> }
>
>
> +/**
> + * svga_reemit_vs_bindings - Reemit the vertex shader bindings
> + */
> +enum pipe_error
> +svga_reemit_vs_bindings(struct svga_context *svga)
> +{
> + enum pipe_error ret;
> + struct svga_winsys_gb_shader *gbshader =
> + svga->state.hw_draw.vs ? svga->state.hw_draw.vs->gb_shader : NULL;
> +
> + assert(svga->rebind.vs);
> + assert(svga_have_gb_objects(svga));
> +
> + ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_VS, gbshader);
> + if (ret != PIPE_OK)
> + return ret;
> +
> + svga->rebind.vs = FALSE;
> + return PIPE_OK;
> +}
> +
>
> static enum pipe_error
> emit_hw_vs(struct svga_context *svga, unsigned dirty)
> {
> struct svga_shader_variant *variant = NULL;
> - unsigned id = SVGA3D_INVALID_ID;
> enum pipe_error ret = PIPE_OK;
>
> /* SVGA_NEW_NEED_SWTNL */
> @@ -184,16 +204,36 @@ emit_hw_vs(struct svga_context *svga, unsigned dirty)
> return ret;
> }
>
> - assert (variant);
> - id = variant->id;
> + assert(variant);
> }
>
> if (variant != svga->state.hw_draw.vs) {
> - ret = SVGA3D_SetShader(svga->swc,
> - SVGA3D_SHADERTYPE_VS,
> - id );
> - if (ret != PIPE_OK)
> - return ret;
> + if (svga_have_gb_objects(svga)) {
> + struct svga_winsys_gb_shader *gbshader =
> + variant ? variant->gb_shader : NULL;
> +
> + /*
> + * Bind is necessary here only because pipebuffer_fenced may move
> + * the shader contents around....
> + */
> + if (gbshader) {
> + ret = SVGA3D_BindGBShader(svga->swc, gbshader);
> + if (ret != PIPE_OK)
> + return ret;
> + }
> +
> + ret = SVGA3D_SetGBShader(svga->swc, SVGA3D_SHADERTYPE_VS, gbshader);
> + if (ret != PIPE_OK)
> + return ret;
> +
> + svga->rebind.vs = FALSE;
> + }
> + else {
> + unsigned id = variant ? variant->id : SVGA_ID_INVALID;
> + ret = SVGA3D_SetShader(svga->swc, SVGA3D_SHADERTYPE_VS, id);
> + if (ret != PIPE_OK)
> + return ret;
> + }
>
> svga->dirty |= SVGA_NEW_VS_VARIANT;
> svga->state.hw_draw.vs = variant;
> diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h
> index 9a0c7b8..4fe88b3 100644
> --- a/src/gallium/drivers/svga/svga_tgsi.h
> +++ b/src/gallium/drivers/svga/svga_tgsi.h
> @@ -106,6 +106,9 @@ struct svga_shader_variant
> */
> unsigned id;
>
> + /* GB object buffer containing the bytecode */
> + struct svga_winsys_gb_shader *gb_shader;
> +
> /** Next variant */
> struct svga_shader_variant *next;
> };
>
More information about the mesa-dev
mailing list