wined3d: Implement locally defined boolean and integer constants in GLSL.

This commit is contained in:
Jason Green 2006-06-16 16:08:00 -04:00 committed by Alexandre Julliard
parent 34d271bab6
commit f444009bfb
4 changed files with 32 additions and 5 deletions

View File

@ -947,7 +947,7 @@ void shader_glsl_lrp(SHADER_OPCODE_ARG* arg) {
tmpLine, src2_str, src1_str, src0_str, src0_str, dst_mask);
}
/** Process the D3DSIO_DCL opcode into a GLSL string - creates a local vec4
/** Process the D3DSIO_DEF opcode into a GLSL string - creates a local vec4
* float constant, and stores it's usage on the regmaps. */
void shader_glsl_def(SHADER_OPCODE_ARG* arg) {
@ -967,6 +967,31 @@ void shader_glsl_def(SHADER_OPCODE_ARG* arg) {
arg->reg_maps->constantsF[reg] = 1;
}
/** Process the D3DSIO_DEFI opcode into a GLSL string - creates a local ivec4
* integer constant, and stores it's usage on the regmaps. */
void shader_glsl_defi(SHADER_OPCODE_ARG* arg) {
DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
shader_addline(arg->buffer,
"const ivec4 I%lu = { %ld, %ld, %ld, %ld };\n", reg,
(long)arg->src[0], (long)arg->src[1],
(long)arg->src[2], (long)arg->src[3]);
arg->reg_maps->constantsI[reg] = 1;
}
/** Process the D3DSIO_DEFB opcode into a GLSL string - creates a local boolean
* constant, and stores it's usage on the regmaps. */
void shader_glsl_defb(SHADER_OPCODE_ARG* arg) {
DWORD reg = arg->dst & D3DSP_REGNUM_MASK;
shader_addline(arg->buffer, "const bool B%lu = %s;\n", reg, (arg->src[0]) ? "true" : "false");
arg->reg_maps->constantsB[reg] = 1;
}
/** Process the D3DSIO_LIT instruction in GLSL:
* dst.x = dst.w = 1.0
* dst.y = (src0.x > 0) ? src0.x

View File

@ -707,8 +707,8 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
/* Constant definitions */
{D3DSIO_DEF, "def", "undefined", 1, 5, pshader_def, shader_hw_def, shader_glsl_def, 0, 0},
{D3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, pshader_defb, NULL, NULL, 0, 0},
{D3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, pshader_defi, NULL, NULL, 0, 0},
{D3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, pshader_defb, NULL, shader_glsl_defb, 0, 0},
{D3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, pshader_defi, NULL, shader_glsl_defi, 0, 0},
/* Texture */
{D3DSIO_TEXCOORD, "texcoord", "undefined", 1, 1, pshader_texcoord, pshader_hw_texcoord, pshader_glsl_texcoord, 0, D3DPS_VERSION(1,3)},

View File

@ -536,8 +536,8 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
/* Constant definitions */
{D3DSIO_DEF, "def", NULL, 1, 5, vshader_def, shader_hw_def, shader_glsl_def, 0, 0},
{D3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, vshader_defb, NULL, NULL, 0, 0},
{D3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, vshader_defi, NULL, NULL, 0, 0},
{D3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, vshader_defb, NULL, shader_glsl_defb, 0, 0},
{D3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, vshader_defi, NULL, shader_glsl_defi, 0, 0},
/* Flow control - requires GLSL or software shaders */
{D3DSIO_REP , "rep", GLNAME_REQUIRE_GLSL, 0, 1, vshader_rep, NULL, NULL, 0, 0},

View File

@ -1376,6 +1376,8 @@ extern void shader_glsl_rcp(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_cnd(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_compare(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_def(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_defi(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_defb(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_cmp(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_lit(SHADER_OPCODE_ARG* arg);
extern void shader_glsl_dst(SHADER_OPCODE_ARG* arg);