summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorCharmaine Lee <[email protected]>2019-03-05 19:36:48 -0700
committerBrian Paul <[email protected]>2019-03-08 07:40:34 -0700
commitdaf567f79745dc0bdfa34966fed646cabd5bf563 (patch)
tree357c2735258394c8d468e9a0059d6df4d099a703 /src/gallium
parentac6b33a50da7d0a46e9981dcc7f6b78bd94741e8 (diff)
svga: add svga shader type in the shader variant
With this patch, the svga shader type will be saved in the shader variant, and there is no need to pass in the shader type to the define/destroy variant functions. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/svga/svga_pipe_fs.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_gs.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_vs.c2
-rw-r--r--src/gallium/drivers/svga/svga_shader.c31
-rw-r--r--src/gallium/drivers/svga/svga_shader.h7
-rw-r--r--src/gallium/drivers/svga/svga_state_fs.c6
-rw-r--r--src/gallium/drivers/svga/svga_state_gs.c4
-rw-r--r--src/gallium/drivers/svga/svga_state_vs.c6
-rw-r--r--src/gallium/drivers/svga/svga_tgsi.c2
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_vgpu10.c2
10 files changed, 33 insertions, 31 deletions
diff --git a/src/gallium/drivers/svga/svga_pipe_fs.c b/src/gallium/drivers/svga/svga_pipe_fs.c
index 52366f0f216..a2f00b1d290 100644
--- a/src/gallium/drivers/svga/svga_pipe_fs.c
+++ b/src/gallium/drivers/svga/svga_pipe_fs.c
@@ -108,7 +108,7 @@ svga_delete_fs_state(struct pipe_context *pipe, void *shader)
svga->state.hw_draw.fs = NULL;
}
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant);
+ svga_destroy_shader_variant(svga, variant);
}
FREE((void *)fs->base.tokens);
diff --git a/src/gallium/drivers/svga/svga_pipe_gs.c b/src/gallium/drivers/svga/svga_pipe_gs.c
index cee92a0005b..edc03f6b6e1 100644
--- a/src/gallium/drivers/svga/svga_pipe_gs.c
+++ b/src/gallium/drivers/svga/svga_pipe_gs.c
@@ -120,7 +120,7 @@ svga_delete_gs_state(struct pipe_context *pipe, void *shader)
svga->state.hw_draw.gs = NULL;
}
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant);
+ svga_destroy_shader_variant(svga, variant);
}
FREE((void *)gs->base.tokens);
diff --git a/src/gallium/drivers/svga/svga_pipe_vs.c b/src/gallium/drivers/svga/svga_pipe_vs.c
index 3b6d2e9ad2f..a475e000f2e 100644
--- a/src/gallium/drivers/svga/svga_pipe_vs.c
+++ b/src/gallium/drivers/svga/svga_pipe_vs.c
@@ -199,7 +199,7 @@ svga_delete_vs_state(struct pipe_context *pipe, void *shader)
svga->state.hw_draw.vs = NULL;
}
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
+ svga_destroy_shader_variant(svga, variant);
}
FREE((void *)vs->base.tokens);
diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
index 22e449835d5..0dfab92814d 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -366,7 +366,6 @@ svga_search_shader_token_key(struct svga_shader *pshader,
*/
static enum pipe_error
define_gb_shader_vgpu9(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant,
unsigned codeLen)
{
@@ -378,7 +377,7 @@ define_gb_shader_vgpu9(struct svga_context *svga,
* Kernel module will allocate an id for the shader and issue
* the DefineGBShader command.
*/
- variant->gb_shader = sws->shader_create(sws, type,
+ variant->gb_shader = sws->shader_create(sws, variant->type,
variant->tokens, codeLen);
if (!variant->gb_shader)
@@ -394,7 +393,6 @@ define_gb_shader_vgpu9(struct svga_context *svga,
*/
static enum pipe_error
define_gb_shader_vgpu10(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant,
unsigned codeLen)
{
@@ -413,7 +411,7 @@ define_gb_shader_vgpu10(struct svga_context *svga,
/* Create gb memory for the shader and upload the shader code */
variant->gb_shader = swc->shader_create(swc,
- variant->id, type,
+ variant->id, variant->type,
variant->tokens, codeLen);
if (!variant->gb_shader) {
@@ -431,7 +429,7 @@ define_gb_shader_vgpu10(struct svga_context *svga,
* the shader creation and return an error.
*/
ret = SVGA3D_vgpu10_DefineAndBindShader(swc, variant->gb_shader,
- variant->id, type, codeLen);
+ variant->id, variant->type, codeLen);
if (ret != PIPE_OK)
goto fail;
@@ -456,7 +454,6 @@ fail_no_allocation:
*/
enum pipe_error
svga_define_shader(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant)
{
unsigned codeLen = variant->nr_tokens * sizeof(variant->tokens[0]);
@@ -468,9 +465,9 @@ svga_define_shader(struct svga_context *svga,
if (svga_have_gb_objects(svga)) {
if (svga_have_vgpu10(svga))
- ret = define_gb_shader_vgpu10(svga, type, variant, codeLen);
+ ret = define_gb_shader_vgpu10(svga, variant, codeLen);
else
- ret = define_gb_shader_vgpu9(svga, type, variant, codeLen);
+ ret = define_gb_shader_vgpu9(svga, variant, codeLen);
}
else {
/* Allocate an integer ID for the shader */
@@ -483,7 +480,7 @@ svga_define_shader(struct svga_context *svga,
/* Issue SVGA3D device command to define the shader */
ret = SVGA3D_DefineShader(svga->swc,
variant->id,
- type,
+ variant->type,
variant->tokens,
codeLen);
if (ret != PIPE_OK) {
@@ -534,16 +531,20 @@ svga_set_shader(struct svga_context *svga,
struct svga_shader_variant *
-svga_new_shader_variant(struct svga_context *svga)
+svga_new_shader_variant(struct svga_context *svga, enum pipe_shader_type type)
{
- svga->hud.num_shaders++;
- return CALLOC_STRUCT(svga_shader_variant);
+ struct svga_shader_variant *variant = CALLOC_STRUCT(svga_shader_variant);
+
+ if (variant) {
+ variant->type = svga_shader_type(type);
+ svga->hud.num_shaders++;
+ }
+ return variant;
}
void
svga_destroy_shader_variant(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant)
{
enum pipe_error ret = PIPE_OK;
@@ -569,11 +570,11 @@ svga_destroy_shader_variant(struct svga_context *svga,
}
else {
if (variant->id != UTIL_BITMASK_INVALID_INDEX) {
- ret = SVGA3D_DestroyShader(svga->swc, variant->id, type);
+ ret = SVGA3D_DestroyShader(svga->swc, variant->id, variant->type);
if (ret != PIPE_OK) {
/* flush and try again */
svga_context_flush(svga, NULL);
- ret = SVGA3D_DestroyShader(svga->swc, variant->id, type);
+ ret = SVGA3D_DestroyShader(svga->swc, variant->id, variant->type);
assert(ret == PIPE_OK);
}
util_bitmask_clear(svga->shader_id_bm, variant->id);
diff --git a/src/gallium/drivers/svga/svga_shader.h b/src/gallium/drivers/svga/svga_shader.h
index 68991e72641..67f6b5aeb63 100644
--- a/src/gallium/drivers/svga/svga_shader.h
+++ b/src/gallium/drivers/svga/svga_shader.h
@@ -135,6 +135,9 @@ struct svga_shader_variant
/** Parameters used to generate this variant */
struct svga_compile_key key;
+ /* svga shader type */
+ SVGA3dShaderType type;
+
/* Compiled shader tokens:
*/
const unsigned *tokens;
@@ -274,7 +277,6 @@ svga_search_shader_token_key(struct svga_shader *shader,
enum pipe_error
svga_define_shader(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant);
enum pipe_error
@@ -283,11 +285,10 @@ svga_set_shader(struct svga_context *svga,
struct svga_shader_variant *variant);
struct svga_shader_variant *
-svga_new_shader_variant(struct svga_context *svga);
+svga_new_shader_variant(struct svga_context *svga, enum pipe_shader_type type);
void
svga_destroy_shader_variant(struct svga_context *svga,
- SVGA3dShaderType type,
struct svga_shader_variant *variant);
enum pipe_error
diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c
index 73f8856b159..74c19926bc9 100644
--- a/src/gallium/drivers/svga/svga_state_fs.c
+++ b/src/gallium/drivers/svga/svga_state_fs.c
@@ -149,7 +149,7 @@ compile_fs(struct svga_context *svga,
(unsigned) (variant->nr_tokens
* sizeof(variant->tokens[0])));
/* Free the too-large variant */
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant);
+ svga_destroy_shader_variant(svga, variant);
/* Use simple pass-through shader instead */
variant = get_compiled_dummy_shader(svga, fs, key);
}
@@ -158,9 +158,9 @@ compile_fs(struct svga_context *svga,
return PIPE_ERROR;
}
- ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_PS, variant);
+ ret = svga_define_shader(svga, variant);
if (ret != PIPE_OK) {
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_PS, variant);
+ svga_destroy_shader_variant(svga, variant);
return ret;
}
diff --git a/src/gallium/drivers/svga/svga_state_gs.c b/src/gallium/drivers/svga/svga_state_gs.c
index b87209312a9..1eb4cebc08d 100644
--- a/src/gallium/drivers/svga/svga_state_gs.c
+++ b/src/gallium/drivers/svga/svga_state_gs.c
@@ -87,9 +87,9 @@ compile_gs(struct svga_context *svga,
}
}
- ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_GS, variant);
+ ret = svga_define_shader(svga, variant);
if (ret != PIPE_OK) {
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_GS, variant);
+ svga_destroy_shader_variant(svga, variant);
return ret;
}
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index ad93f60048a..d63b52454ca 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -138,7 +138,7 @@ compile_vs(struct svga_context *svga,
(unsigned) (variant->nr_tokens
* sizeof(variant->tokens[0])));
/* Free the too-large variant */
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
+ svga_destroy_shader_variant(svga, variant);
/* Use simple pass-through shader instead */
variant = get_compiled_dummy_vertex_shader(svga, vs, key);
}
@@ -147,9 +147,9 @@ compile_vs(struct svga_context *svga,
return PIPE_ERROR;
}
- ret = svga_define_shader(svga, SVGA3D_SHADERTYPE_VS, variant);
+ ret = svga_define_shader(svga, variant);
if (ret != PIPE_OK) {
- svga_destroy_shader_variant(svga, SVGA3D_SHADERTYPE_VS, variant);
+ svga_destroy_shader_variant(svga, variant);
return ret;
}
diff --git a/src/gallium/drivers/svga/svga_tgsi.c b/src/gallium/drivers/svga/svga_tgsi.c
index 8819313fb54..5c3afee3845 100644
--- a/src/gallium/drivers/svga/svga_tgsi.c
+++ b/src/gallium/drivers/svga/svga_tgsi.c
@@ -228,7 +228,7 @@ svga_tgsi_vgpu9_translate(struct svga_context *svga,
goto fail;
}
- variant = svga_new_shader_variant(svga);
+ variant = svga_new_shader_variant(svga, unit);
if (!variant)
goto fail;
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index a5bbb4d0f2a..099ede6017d 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -7066,7 +7066,7 @@ svga_tgsi_vgpu10_translate(struct svga_context *svga,
/*
* Create, initialize the 'variant' object.
*/
- variant = svga_new_shader_variant(svga);
+ variant = svga_new_shader_variant(svga, unit);
if (!variant)
goto cleanup;