d3dcompiler_43: Add a helper function for register token to avoid compiler warnings.

This commit is contained in:
Alexandre Julliard 2015-06-26 18:26:46 +09:00
parent c17c54318a
commit 8a9483400a
1 changed files with 39 additions and 92 deletions

View File

@ -571,6 +571,13 @@ static DWORD d3d9_opcode(DWORD bwriter_opcode)
} }
} }
static DWORD d3dsp_register( D3DSHADER_PARAM_REGISTER_TYPE type, DWORD num )
{
return ((type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK) |
((type << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2) |
(num & D3DSP_REGNUM_MASK); /* No shift */
}
/****************************************************** /******************************************************
* Implementation of the writer functions starts here * * Implementation of the writer functions starts here *
******************************************************/ ******************************************************/
@ -611,10 +618,7 @@ static void write_declarations(struct bc_writer *This,
static void write_const(struct constant **consts, int num, DWORD opcode, DWORD reg_type, struct bytecode_buffer *buffer, BOOL len) { static void write_const(struct constant **consts, int num, DWORD opcode, DWORD reg_type, struct bytecode_buffer *buffer, BOOL len) {
int i; int i;
DWORD instr_def = opcode; DWORD instr_def = opcode;
const DWORD reg = (1<<31) | const DWORD reg = (1<<31) | d3dsp_register( reg_type, 0 ) | D3DSP_WRITEMASK_ALL;
((reg_type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK) |
((reg_type << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2) |
D3DSP_WRITEMASK_ALL;
if(len) { if(len) {
if(opcode == D3DSIO_DEFB) if(opcode == D3DSIO_DEFB)
@ -849,41 +853,28 @@ static void end(struct bc_writer *This, const struct bwriter_shader *shader, str
} }
static DWORD map_vs_output(struct bc_writer *This, DWORD regnum, DWORD mask, DWORD *has_components) { static DWORD map_vs_output(struct bc_writer *This, DWORD regnum, DWORD mask, DWORD *has_components) {
DWORD token = 0;
DWORD i; DWORD i;
*has_components = TRUE; *has_components = TRUE;
if(regnum == This->oPos_regnum) { if(regnum == This->oPos_regnum) {
token |= (D3DSPR_RASTOUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_RASTOUT, D3DSRO_POSITION );
token |= D3DSRO_POSITION & D3DSP_REGNUM_MASK; /* No shift */
return token;
} }
if(regnum == This->oFog_regnum && mask == This->oFog_mask) { if(regnum == This->oFog_regnum && mask == This->oFog_mask) {
token |= (D3DSPR_RASTOUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK;
token |= D3DSRO_FOG & D3DSP_REGNUM_MASK; /* No shift */
token |= D3DSP_WRITEMASK_ALL;
*has_components = FALSE; *has_components = FALSE;
return token; return d3dsp_register( D3DSPR_RASTOUT, D3DSRO_FOG ) | D3DSP_WRITEMASK_ALL;
} }
if(regnum == This->oPts_regnum && mask == This->oPts_mask) { if(regnum == This->oPts_regnum && mask == This->oPts_mask) {
token |= (D3DSPR_RASTOUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK;
token |= D3DSRO_POINT_SIZE & D3DSP_REGNUM_MASK; /* No shift */
token |= D3DSP_WRITEMASK_ALL;
*has_components = FALSE; *has_components = FALSE;
return token; return d3dsp_register( D3DSPR_RASTOUT, D3DSRO_POINT_SIZE ) | D3DSP_WRITEMASK_ALL;
} }
for(i = 0; i < 2; i++) { for(i = 0; i < 2; i++) {
if(regnum == This->oD_regnum[i]) { if(regnum == This->oD_regnum[i]) {
token |= (D3DSPR_ATTROUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_ATTROUT, i );
token |= i & D3DSP_REGNUM_MASK; /* No shift */
return token;
} }
} }
for(i = 0; i < 8; i++) { for(i = 0; i < 8; i++) {
if(regnum == This->oT_regnum[i]) { if(regnum == This->oT_regnum[i]) {
token |= (D3DSPR_TEXCRDOUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXCRDOUT, i );
token |= i & D3DSP_REGNUM_MASK; /* No shift */
return token;
} }
} }
@ -922,8 +913,7 @@ static void vs_12_dstreg(struct bc_writer *This, const struct shader_reg *reg,
case BWRITERSPR_INPUT: case BWRITERSPR_INPUT:
case BWRITERSPR_TEMP: case BWRITERSPR_TEMP:
case BWRITERSPR_CONST: case BWRITERSPR_CONST:
token |= (reg->type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( reg->type, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
has_wmask = TRUE; has_wmask = TRUE;
break; break;
@ -933,8 +923,7 @@ static void vs_12_dstreg(struct bc_writer *This, const struct shader_reg *reg,
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
return; return;
} }
token |= (D3DSPR_ADDR << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_ADDR, 0 );
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
has_wmask = TRUE; has_wmask = TRUE;
break; break;
@ -949,9 +938,7 @@ static void vs_12_dstreg(struct bc_writer *This, const struct shader_reg *reg,
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
return; return;
} }
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_PREDICATE, 0 );
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
has_wmask = TRUE; has_wmask = TRUE;
break; break;
@ -1015,8 +1002,7 @@ static void vs_1_x_srcreg(struct bc_writer *This, const struct shader_reg *reg,
case BWRITERSPR_TEMP: case BWRITERSPR_TEMP:
case BWRITERSPR_CONST: case BWRITERSPR_CONST:
case BWRITERSPR_ADDR: case BWRITERSPR_ADDR:
token |= (reg->type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( reg->type, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
if(reg->rel_reg) { if(reg->rel_reg) {
if(reg->rel_reg->type != BWRITERSPR_ADDR || if(reg->rel_reg->type != BWRITERSPR_ADDR ||
reg->rel_reg->regnum != 0 || reg->rel_reg->regnum != 0 ||
@ -1053,48 +1039,37 @@ static void write_srcregs(struct bc_writer *This, const struct instruction *inst
} }
static DWORD map_ps13_temp(struct bc_writer *This, const struct shader_reg *reg) { static DWORD map_ps13_temp(struct bc_writer *This, const struct shader_reg *reg) {
DWORD token = 0;
if(reg->regnum == T0_REG) { if(reg->regnum == T0_REG) {
token |= (D3DSPR_TEXTURE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXTURE, 0 );
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
} else if(reg->regnum == T1_REG) { } else if(reg->regnum == T1_REG) {
token |= (D3DSPR_TEXTURE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXTURE, 1 );
token |= 1 & D3DSP_REGNUM_MASK; /* No shift */
} else if(reg->regnum == T2_REG) { } else if(reg->regnum == T2_REG) {
token |= (D3DSPR_TEXTURE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXTURE, 2 );
token |= 2 & D3DSP_REGNUM_MASK; /* No shift */
} else if(reg->regnum == T3_REG) { } else if(reg->regnum == T3_REG) {
token |= (D3DSPR_TEXTURE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXTURE, 3 );
token |= 3 & D3DSP_REGNUM_MASK; /* No shift */
} else { } else {
token |= (D3DSPR_TEMP << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEMP, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
} }
return token;
} }
static DWORD map_ps_input(struct bc_writer *This, static DWORD map_ps_input(struct bc_writer *This,
const struct shader_reg *reg) { const struct shader_reg *reg) {
DWORD i, token = 0; DWORD i;
/* Map color interpolators */ /* Map color interpolators */
for(i = 0; i < 2; i++) { for(i = 0; i < 2; i++) {
if(reg->regnum == This->v_regnum[i]) { if(reg->regnum == This->v_regnum[i]) {
token |= (D3DSPR_INPUT << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_INPUT, i );
token |= i & D3DSP_REGNUM_MASK; /* No shift */
return token;
} }
} }
for(i = 0; i < 8; i++) { for(i = 0; i < 8; i++) {
if(reg->regnum == This->t_regnum[i]) { if(reg->regnum == This->t_regnum[i]) {
token |= (D3DSPR_TEXTURE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; return d3dsp_register( D3DSPR_TEXTURE, i );
token |= i & D3DSP_REGNUM_MASK; /* No shift */
return token;
} }
} }
WARN("Invalid ps 1/2 varying\n"); WARN("Invalid ps 1/2 varying\n");
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
return token; return 0;
} }
static void ps_1_0123_srcreg(struct bc_writer *This, const struct shader_reg *reg, static void ps_1_0123_srcreg(struct bc_writer *This, const struct shader_reg *reg,
@ -1120,8 +1095,7 @@ static void ps_1_0123_srcreg(struct bc_writer *This, const struct shader_reg *re
break; break;
case BWRITERSPR_CONST: /* Can be mapped 1:1 */ case BWRITERSPR_CONST: /* Can be mapped 1:1 */
token |= (reg->type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( reg->type, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
default: default:
@ -1423,8 +1397,7 @@ static void ps_1_4_srcreg(struct bc_writer *This, const struct shader_reg *reg,
/* Can be mapped 1:1 */ /* Can be mapped 1:1 */
case BWRITERSPR_TEMP: case BWRITERSPR_TEMP:
case BWRITERSPR_CONST: case BWRITERSPR_CONST:
token |= (reg->type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( reg->type, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
default: default:
@ -1458,8 +1431,7 @@ static void ps_1_4_dstreg(struct bc_writer *This, const struct shader_reg *reg,
switch(reg->type) { switch(reg->type) {
case BWRITERSPR_TEMP: /* 1:1 mapping */ case BWRITERSPR_TEMP: /* 1:1 mapping */
token |= (reg->type << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( reg->type, reg->regnum );
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
/* For texkill */ /* For texkill */
@ -1640,9 +1612,7 @@ static void vs_2_srcreg(struct bc_writer *This,
case BWRITERSPR_CONSTBOOL: case BWRITERSPR_CONSTBOOL:
case BWRITERSPR_LABEL: case BWRITERSPR_LABEL:
d3d9reg = d3d9_register(reg->type); d3d9reg = d3d9_register(reg->type);
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( d3d9reg, reg->regnum );
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
case BWRITERSPR_LOOP: case BWRITERSPR_LOOP:
@ -1651,9 +1621,7 @@ static void vs_2_srcreg(struct bc_writer *This,
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
return; return;
} }
token |= (D3DSPR_LOOP << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_LOOP, 0 );
token |= (D3DSPR_LOOP << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
break; break;
case BWRITERSPR_PREDICATE: case BWRITERSPR_PREDICATE:
@ -1667,10 +1635,7 @@ static void vs_2_srcreg(struct bc_writer *This,
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
return; return;
} }
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_PREDICATE, 0 );
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
break; break;
default: default:
@ -1838,10 +1803,7 @@ static void write_samplers(const struct bwriter_shader *shader, struct bytecode_
DWORD i; DWORD i;
DWORD instr_dcl = D3DSIO_DCL | (2 << D3DSI_INSTLENGTH_SHIFT); DWORD instr_dcl = D3DSIO_DCL | (2 << D3DSI_INSTLENGTH_SHIFT);
DWORD token; DWORD token;
const DWORD reg = (1<<31) | const DWORD reg = (1<<31) | d3dsp_register( D3DSPR_SAMPLER, 0 ) | D3DSP_WRITEMASK_ALL;
((D3DSPR_SAMPLER << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK) |
((D3DSPR_SAMPLER << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2) |
D3DSP_WRITEMASK_ALL;
for(i = 0; i < shader->num_samplers; i++) { for(i = 0; i < shader->num_samplers; i++) {
/* Write the DCL instruction */ /* Write the DCL instruction */
@ -1896,9 +1858,7 @@ static void ps_2_srcreg(struct bc_writer *This,
case BWRITERSPR_LABEL: case BWRITERSPR_LABEL:
case BWRITERSPR_DEPTHOUT: case BWRITERSPR_DEPTHOUT:
d3d9reg = d3d9_register(reg->type); d3d9reg = d3d9_register(reg->type);
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( d3d9reg, reg->regnum );
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
case BWRITERSPR_PREDICATE: case BWRITERSPR_PREDICATE:
@ -1911,9 +1871,7 @@ static void ps_2_srcreg(struct bc_writer *This,
reg->regnum); reg->regnum);
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
} }
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_PREDICATE, 0 );
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= 0 & D3DSP_REGNUM_MASK; /* No shift */
break; break;
default: default:
@ -1946,9 +1904,7 @@ static void ps_2_0_dstreg(struct bc_writer *This,
case BWRITERSPR_COLOROUT: case BWRITERSPR_COLOROUT:
case BWRITERSPR_DEPTHOUT: case BWRITERSPR_DEPTHOUT:
d3d9reg = d3d9_register(reg->type); d3d9reg = d3d9_register(reg->type);
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( d3d9reg, reg->regnum );
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
case BWRITERSPR_PREDICATE: case BWRITERSPR_PREDICATE:
@ -1956,9 +1912,7 @@ static void ps_2_0_dstreg(struct bc_writer *This,
WARN("Predicate register not supported in ps_2_0\n"); WARN("Predicate register not supported in ps_2_0\n");
This->state = E_INVALIDARG; This->state = E_INVALIDARG;
} }
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( D3DSPR_PREDICATE, reg->regnum );
token |= (D3DSPR_PREDICATE << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
break; break;
/* texkill uses the input register as a destination parameter */ /* texkill uses the input register as a destination parameter */
@ -2113,10 +2067,7 @@ static void sm_3_srcreg(struct bc_writer *This,
DWORD d3d9reg; DWORD d3d9reg;
d3d9reg = d3d9_register(reg->type); d3d9reg = d3d9_register(reg->type);
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( d3d9reg, reg->regnum );
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK;
token |= d3d9_swizzle(reg->u.swizzle) & D3DVS_SWIZZLE_MASK; token |= d3d9_swizzle(reg->u.swizzle) & D3DVS_SWIZZLE_MASK;
token |= d3d9_srcmod(reg->srcmod); token |= d3d9_srcmod(reg->srcmod);
@ -2166,12 +2117,8 @@ static void sm_3_dstreg(struct bc_writer *This,
} }
d3d9reg = d3d9_register(reg->type); d3d9reg = d3d9_register(reg->type);
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT) & D3DSP_REGTYPE_MASK; token |= d3dsp_register( d3d9reg, reg->regnum );
token |= (d3d9reg << D3DSP_REGTYPE_SHIFT2) & D3DSP_REGTYPE_MASK2;
token |= reg->regnum & D3DSP_REGNUM_MASK; /* No shift */
token |= d3d9_dstmod(mod); token |= d3d9_dstmod(mod);
token |= d3d9_writemask(reg->u.writemask); token |= d3d9_writemask(reg->u.writemask);
put_dword(buffer, token); put_dword(buffer, token);