summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-08-25 14:22:26 -0400
committerZack Rusin <[email protected]>2009-08-25 14:22:26 -0400
commit7bc4744026fadd3859097bf076e9b345f4e310f4 (patch)
tree471f064ad9d83af74bdebc146e4488277888d45b /src/gallium
parent23b59d3b4029ea89b5a8e85ea3cc10bea1ab01d0 (diff)
xorg: insert shaders into the cache
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index 231077a7530..710b65e6ae4 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -56,6 +56,20 @@ src_in_mask(struct ureg_program *ureg,
ureg_scalar(mask, TGSI_SWIZZLE_W));
}
+static void *
+create_vs(struct pipe_context *ctx,
+ unsigned vs_traits)
+{
+ return NULL;
+}
+
+static void *
+create_fs(struct pipe_context *ctx,
+ unsigned vs_traits)
+{
+ return NULL;
+}
+
static struct xorg_shader
xorg_shader_construct(struct exa_context *exa,
int op,
@@ -154,11 +168,46 @@ void xorg_shaders_destroy(struct xorg_shaders *sc)
free(sc);
}
+static INLINE void *
+shader_from_cache(struct pipe_context *pipe,
+ unsigned type,
+ struct cso_hash *hash,
+ unsigned key)
+{
+ void *shader = 0;
+
+ struct cso_hash_iter iter = cso_hash_find(hash, key);
+
+ if (cso_hash_iter_is_null(iter)) {
+ if (type == PIPE_SHADER_VERTEX)
+ shader = create_vs(pipe, key);
+ else
+ shader = create_fs(pipe, key);
+ cso_hash_insert(hash, key, shader);
+ } else
+ shader = (void *)cso_hash_iter_data(iter);
+
+ return shader;
+}
+
struct xorg_shader xorg_shaders_get(struct xorg_shaders *sc,
unsigned vs_traits,
unsigned fs_traits)
{
struct xorg_shader shader = {0};
+ void *vs, *fs;
+
+ vs = shader_from_cache(sc->exa->ctx, PIPE_SHADER_VERTEX,
+ sc->vs_hash, vs_traits);
+ fs = shader_from_cache(sc->exa->ctx, PIPE_SHADER_FRAGMENT,
+ sc->fs_hash, fs_traits);
+
+ debug_assert(vs && fs);
+ if (!vs || !fs)
+ return shader;
+
+ shader.vs = vs;
+ shader.fs = fs;
return shader;
}