summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/xorg
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/xorg')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.c97
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.h27
2 files changed, 84 insertions, 40 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index 9896d067b2..231077a753 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -15,14 +15,13 @@
#include "tgsi/tgsi_ureg.h"
#include "cso_cache/cso_context.h"
+#include "cso_cache/cso_hash.h"
-#define UNSUPPORTED_OP 0
+struct xorg_shaders {
+ struct exa_context *exa;
-struct shader_id {
- int op : 8;
- int mask : 1;
- int component_alpha : 1;
- int is_fill : 1;
+ struct cso_hash *vs_hash;
+ struct cso_hash *fs_hash;
};
/* SAMP[0] = dst
@@ -57,40 +56,19 @@ src_in_mask(struct ureg_program *ureg,
ureg_scalar(mask, TGSI_SWIZZLE_W));
}
-static INLINE
-struct shader_id shader_state(int op,
- PicturePtr src_picture,
- PicturePtr mask_picture,
- PicturePtr dst_picture)
-{
- struct shader_id sid;
-
- sid.op = op;
- sid.mask = (mask_picture != 0);
- sid.component_alpha = (mask_picture->componentAlpha);
- sid.is_fill = (src_picture->pSourcePict != 0);
- if (sid.is_fill) {
- sid.is_fill =
- (src_picture->pSourcePict->type == SourcePictTypeSolidFill);
- }
-
- return sid;
-}
-
-struct xorg_shader xorg_shader_construct(struct exa_context *exa,
- int op,
- PicturePtr src_picture,
- PicturePtr mask_picture,
- PicturePtr dst_picture)
+static struct xorg_shader
+xorg_shader_construct(struct exa_context *exa,
+ int op,
+ PicturePtr src_picture,
+ PicturePtr mask_picture,
+ PicturePtr dst_picture)
{
+ struct xorg_shader shader = {0};
+#if 0
struct ureg_program *ureg;
struct ureg_src dst_sampler, src_sampler, mask_sampler;
struct ureg_src dst_pos, src_pos, mask_pos;
struct ureg_src src, mask;
- struct shader_id sid = shader_state(op, src_picture,
- mask_picture,
- dst_picture);
- struct xorg_shader shader = {0};
ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
if (ureg == NULL)
@@ -133,5 +111,54 @@ struct xorg_shader xorg_shader_construct(struct exa_context *exa,
ureg_END(ureg);
+#endif
+ return shader;
+}
+
+struct xorg_shaders * xorg_shaders_create(struct exa_context *exa)
+{
+ struct xorg_shaders *sc = CALLOC_STRUCT(xorg_shaders);
+
+ sc->exa = exa;
+ sc->vs_hash = cso_hash_create();
+ sc->fs_hash = cso_hash_create();
+
+ return sc;
+}
+
+static void
+cache_destroy(struct cso_context *cso,
+ struct cso_hash *hash,
+ unsigned processor)
+{
+ struct cso_hash_iter iter = cso_hash_first_node(hash);
+ while (!cso_hash_iter_is_null(iter)) {
+ void *shader = (void *)cso_hash_iter_data(iter);
+ if (processor == PIPE_SHADER_FRAGMENT) {
+ cso_delete_fragment_shader(cso, shader);
+ } else if (processor == PIPE_SHADER_VERTEX) {
+ cso_delete_vertex_shader(cso, shader);
+ }
+ iter = cso_hash_erase(hash, iter);
+ }
+ cso_hash_delete(hash);
+}
+
+void xorg_shaders_destroy(struct xorg_shaders *sc)
+{
+ cache_destroy(sc->exa->cso, sc->vs_hash,
+ PIPE_SHADER_VERTEX);
+ cache_destroy(sc->exa->cso, sc->fs_hash,
+ PIPE_SHADER_FRAGMENT);
+
+ free(sc);
+}
+
+struct xorg_shader xorg_shaders_get(struct xorg_shaders *sc,
+ unsigned vs_traits,
+ unsigned fs_traits)
+{
+ struct xorg_shader shader = {0};
+
return shader;
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
index b7245c8e89..f87f035267 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
@@ -3,15 +3,32 @@
#include "xorg_exa.h"
+enum xorg_vs_traits {
+ VS_COMPOSITE = 1 << 0,
+ VS_FILL = 1 << 1
+ /*VS_TRANSFORM = 1 << 2*/
+};
+
+enum xorg_fs_traits {
+ FS_COMPOSITE = 1 << 0,
+ FS_MASK = 1 << 1,
+ FS_FILL = 1 << 2,
+ FS_LINEAR_GRADIENT = 1 << 3,
+ FS_RADIAL_GRADIENT = 1 << 4
+};
+
struct xorg_shader {
void *fs;
void *vs;
};
-struct xorg_shader xorg_shader_construct(struct exa_context *exa,
- int op,
- PicturePtr src_picture,
- PicturePtr mask_picture,
- PicturePtr dst_picture);
+struct xorg_shaders;
+
+struct xorg_shaders *xorg_shaders_create(struct exa_context *exa);
+void xorg_shaders_destroy(struct xorg_shaders *shaders);
+
+struct xorg_shader xorg_shaders_get(struct xorg_shaders *shaders,
+ unsigned vs_traits,
+ unsigned fs_traits);
#endif