diff options
author | Rob Clark <[email protected]> | 2014-10-14 16:23:18 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2014-10-15 15:49:48 -0400 |
commit | 368466b7b72aed74b917aeb3225d7a0a7101678c (patch) | |
tree | 204b333fa07505888f4aa720af02650d7037304b /src/gallium/drivers/freedreno/ir3/ir3_shader.h | |
parent | d595987ea3d1706fecb9f6416031ec8b27c95a9e (diff) |
freedreno/ir3: optimize shader key comparision
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3/ir3_shader.h')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.h | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index c531ad704cc..628c09e1be3 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -54,36 +54,54 @@ static inline uint16_t sem2idx(ir3_semantic sem) * in hw (two sided color), binning-pass vertex shader, etc. */ struct ir3_shader_key { + union { + struct { + /* do we need to check {v,f}saturate_{s,t,r}? */ + unsigned has_per_samp : 1; + + /* + * Vertex shader variant parameters: + */ + unsigned binning_pass : 1; + + /* + * Fragment shader variant parameters: + */ + unsigned color_two_side : 1; + unsigned half_precision : 1; + /* For rendering to alpha, we need a bit of special handling + * since the hw always takes gl_FragColor starting from x + * component, rather than figuring out to take the w component. + * We could be more clever and generate variants for other + * render target formats (ie. luminance formats are xxx1), but + * let's start with this and see how it goes: + */ + unsigned alpha : 1; + }; + uint32_t global; + }; + /* bitmask of sampler which needs coords clamped for vertex * shader: */ - unsigned vsaturate_s, vsaturate_t, vsaturate_r; + uint16_t vsaturate_s, vsaturate_t, vsaturate_r; /* bitmask of sampler which needs coords clamped for frag * shader: */ - unsigned fsaturate_s, fsaturate_t, fsaturate_r; - - /* - * Vertex shader variant parameters: - */ - unsigned binning_pass : 1; + uint16_t fsaturate_s, fsaturate_t, fsaturate_r; - /* - * Fragment shader variant parameters: - */ - unsigned color_two_side : 1; - unsigned half_precision : 1; - /* For rendering to alpha, we need a bit of special handling - * since the hw always takes gl_FragColor starting from x - * component, rather than figuring out to take the w component. - * We could be more clever and generate variants for other - * render target formats (ie. luminance formats are xxx1), but - * let's start with this and see how it goes: - */ - unsigned alpha : 1; }; +static inline bool +ir3_shader_key_equal(struct ir3_shader_key *a, struct ir3_shader_key *b) +{ + /* slow-path if we need to check {v,f}saturate_{s,t,r} */ + if (a->has_per_samp || b->has_per_samp) + return memcmp(a, b, sizeof(struct ir3_shader_key)) == 0; + return a->global == b->global; +} + struct ir3_shader_variant { struct fd_bo *bo; |