aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_decl_sm30.c20
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_emit.h125
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_insn.c129
3 files changed, 149 insertions, 125 deletions
diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
index becd159b79f..7faa275f33e 100644
--- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
+++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
@@ -491,6 +491,26 @@ vs30_output(struct svga_shader_emitter *emit,
}
+/** Translate PIPE_TEXTURE_x to SVGA3DSAMP_x */
+static ubyte
+svga_tgsi_sampler_type(const struct svga_shader_emitter *emit, int idx)
+{
+ switch (emit->key.fkey.tex[idx].texture_target) {
+ case PIPE_TEXTURE_1D:
+ return SVGA3DSAMP_2D;
+ case PIPE_TEXTURE_2D:
+ case PIPE_TEXTURE_RECT:
+ return SVGA3DSAMP_2D;
+ case PIPE_TEXTURE_3D:
+ return SVGA3DSAMP_VOLUME;
+ case PIPE_TEXTURE_CUBE:
+ return SVGA3DSAMP_CUBE;
+ }
+
+ return SVGA3DSAMP_UNKNOWN;
+}
+
+
static boolean
ps30_sampler( struct svga_shader_emitter *emit,
struct tgsi_declaration_semantic semantic,
diff --git a/src/gallium/drivers/svga/svga_tgsi_emit.h b/src/gallium/drivers/svga/svga_tgsi_emit.h
index 73c4cdabefc..949c39dd3ee 100644
--- a/src/gallium/drivers/svga/svga_tgsi_emit.h
+++ b/src/gallium/drivers/svga/svga_tgsi_emit.h
@@ -146,30 +146,6 @@ boolean svga_translate_decl_sm30( struct svga_shader_emitter *emit,
const struct tgsi_full_declaration *decl );
-static INLINE boolean emit_dst( struct svga_shader_emitter *emit,
- SVGA3dShaderDestToken dest )
-{
- assert(dest.reserved0);
- assert(dest.mask);
- return svga_shader_emit_dword( emit, dest.value );
-}
-
-static INLINE boolean emit_src( struct svga_shader_emitter *emit,
- const struct src_register src )
-{
- if (src.base.relAddr) {
- assert(src.base.reserved0);
- assert(src.indirect.reserved0);
- return (svga_shader_emit_dword( emit, src.base.value ) &&
- svga_shader_emit_dword( emit, src.indirect.value ));
- }
- else {
- assert(src.base.reserved0);
- return svga_shader_emit_dword( emit, src.base.value );
- }
-}
-
-
static INLINE boolean emit_instruction( struct svga_shader_emitter *emit,
SVGA3dShaderInstToken opcode )
{
@@ -177,60 +153,6 @@ static INLINE boolean emit_instruction( struct svga_shader_emitter *emit,
}
-static INLINE boolean emit_op1( struct svga_shader_emitter *emit,
- SVGA3dShaderInstToken inst,
- SVGA3dShaderDestToken dest,
- struct src_register src0 )
-{
- return (emit_instruction( emit, inst ) &&
- emit_dst( emit, dest ) &&
- emit_src( emit, src0 ));
-}
-
-static INLINE boolean emit_op2( struct svga_shader_emitter *emit,
- SVGA3dShaderInstToken inst,
- SVGA3dShaderDestToken dest,
- struct src_register src0,
- struct src_register src1 )
-{
- return (emit_instruction( emit, inst ) &&
- emit_dst( emit, dest ) &&
- emit_src( emit, src0 ) &&
- emit_src( emit, src1 ));
-}
-
-static INLINE boolean emit_op3( struct svga_shader_emitter *emit,
- SVGA3dShaderInstToken inst,
- SVGA3dShaderDestToken dest,
- struct src_register src0,
- struct src_register src1,
- struct src_register src2 )
-{
- return (emit_instruction( emit, inst ) &&
- emit_dst( emit, dest ) &&
- emit_src( emit, src0 ) &&
- emit_src( emit, src1 ) &&
- emit_src( emit, src2 ));
-}
-
-
-static INLINE boolean emit_op4( struct svga_shader_emitter *emit,
- SVGA3dShaderInstToken inst,
- SVGA3dShaderDestToken dest,
- struct src_register src0,
- struct src_register src1,
- struct src_register src2,
- struct src_register src3)
-{
- return (emit_instruction( emit, inst ) &&
- emit_dst( emit, dest ) &&
- emit_src( emit, src0 ) &&
- emit_src( emit, src1 ) &&
- emit_src( emit, src2 ) &&
- emit_src( emit, src3 ));
-}
-
-
#define TRANSLATE_SWIZZLE(x,y,z,w) ((x) | ((y) << 2) | ((z) << 4) | ((w) << 6))
#define SWIZZLE_XYZW \
TRANSLATE_SWIZZLE(TGSI_SWIZZLE_X,TGSI_SWIZZLE_Y,TGSI_SWIZZLE_Z,TGSI_SWIZZLE_W)
@@ -320,36 +242,6 @@ src_token( unsigned file, int number )
static INLINE struct src_register
-absolute( struct src_register src )
-{
- src.base.srcMod = SVGA3DSRCMOD_ABS;
-
- return src;
-}
-
-
-static INLINE struct src_register
-negate( struct src_register src )
-{
- switch (src.base.srcMod) {
- case SVGA3DSRCMOD_ABS:
- src.base.srcMod = SVGA3DSRCMOD_ABSNEG;
- break;
- case SVGA3DSRCMOD_ABSNEG:
- src.base.srcMod = SVGA3DSRCMOD_ABS;
- break;
- case SVGA3DSRCMOD_NEG:
- src.base.srcMod = SVGA3DSRCMOD_NONE;
- break;
- case SVGA3DSRCMOD_NONE:
- src.base.srcMod = SVGA3DSRCMOD_NEG;
- break;
- }
- return src;
-}
-
-
-static INLINE struct src_register
src_register( unsigned file, int number )
{
struct src_register src;
@@ -372,22 +264,5 @@ static INLINE struct src_register src( SVGA3dShaderDestToken dst )
dst.num );
}
-static INLINE ubyte svga_tgsi_sampler_type( struct svga_shader_emitter *emit,
- int idx )
-{
- switch (emit->key.fkey.tex[idx].texture_target) {
- case PIPE_TEXTURE_1D:
- return SVGA3DSAMP_2D;
- case PIPE_TEXTURE_2D:
- case PIPE_TEXTURE_RECT:
- return SVGA3DSAMP_2D;
- case PIPE_TEXTURE_3D:
- return SVGA3DSAMP_VOLUME;
- case PIPE_TEXTURE_CUBE:
- return SVGA3DSAMP_CUBE;
- }
-
- return SVGA3DSAMP_UNKNOWN;
-}
#endif
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index 1e0579d95e6..92ee444a0db 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -292,6 +292,135 @@ reset_temp_regs(struct svga_shader_emitter *emit)
}
+/** Emit bytecode for a src_register */
+static boolean
+emit_src(struct svga_shader_emitter *emit, const struct src_register src)
+{
+ if (src.base.relAddr) {
+ assert(src.base.reserved0);
+ assert(src.indirect.reserved0);
+ return (svga_shader_emit_dword( emit, src.base.value ) &&
+ svga_shader_emit_dword( emit, src.indirect.value ));
+ }
+ else {
+ assert(src.base.reserved0);
+ return svga_shader_emit_dword( emit, src.base.value );
+ }
+}
+
+
+/** Emit bytecode for a dst_register */
+static boolean
+emit_dst(struct svga_shader_emitter *emit, SVGA3dShaderDestToken dest)
+{
+ assert(dest.reserved0);
+ assert(dest.mask);
+ return svga_shader_emit_dword( emit, dest.value );
+}
+
+
+/** Emit bytecode for a 1-operand instruction */
+static boolean
+emit_op1(struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0)
+{
+ return (emit_instruction(emit, inst) &&
+ emit_dst(emit, dest) &&
+ emit_src(emit, src0));
+}
+
+
+/** Emit bytecode for a 2-operand instruction */
+static boolean
+emit_op2(struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0,
+ struct src_register src1)
+{
+ return (emit_instruction(emit, inst) &&
+ emit_dst(emit, dest) &&
+ emit_src(emit, src0) &&
+ emit_src(emit, src1));
+}
+
+
+/** Emit bytecode for a 3-operand instruction */
+static boolean
+emit_op3(struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0,
+ struct src_register src1,
+ struct src_register src2)
+{
+ return (emit_instruction(emit, inst) &&
+ emit_dst(emit, dest) &&
+ emit_src(emit, src0) &&
+ emit_src(emit, src1) &&
+ emit_src(emit, src2));
+}
+
+
+/** Emit bytecode for a 4-operand instruction */
+static boolean
+emit_op4(struct svga_shader_emitter *emit,
+ SVGA3dShaderInstToken inst,
+ SVGA3dShaderDestToken dest,
+ struct src_register src0,
+ struct src_register src1,
+ struct src_register src2,
+ struct src_register src3)
+{
+ return (emit_instruction(emit, inst) &&
+ emit_dst(emit, dest) &&
+ emit_src(emit, src0) &&
+ emit_src(emit, src1) &&
+ emit_src(emit, src2) &&
+ emit_src(emit, src3));
+}
+
+
+/**
+ * Apply the absolute value modifier to the given src_register, returning
+ * a new src_register.
+ */
+static struct src_register
+absolute(struct src_register src)
+{
+ src.base.srcMod = SVGA3DSRCMOD_ABS;
+ return src;
+}
+
+
+/**
+ * Apply the negation modifier to the given src_register, returning
+ * a new src_register.
+ */
+static struct src_register
+negate(struct src_register src)
+{
+ switch (src.base.srcMod) {
+ case SVGA3DSRCMOD_ABS:
+ src.base.srcMod = SVGA3DSRCMOD_ABSNEG;
+ break;
+ case SVGA3DSRCMOD_ABSNEG:
+ src.base.srcMod = SVGA3DSRCMOD_ABS;
+ break;
+ case SVGA3DSRCMOD_NEG:
+ src.base.srcMod = SVGA3DSRCMOD_NONE;
+ break;
+ case SVGA3DSRCMOD_NONE:
+ src.base.srcMod = SVGA3DSRCMOD_NEG;
+ break;
+ }
+ return src;
+}
+
+
+
/* Replace the src with the temporary specified in the dst, but copying
* only the necessary channels, and preserving the original swizzle (which is
* important given that several opcodes have constraints in the allowed