wined3d: Store the sampler type in struct shader_reg_maps.
Instead of the usage token.
This commit is contained in:
parent
54d7c8012d
commit
8d4c90496f
|
@ -659,7 +659,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
|
|||
const char *dst_str, const char *coord_reg, BOOL projected, BOOL bias)
|
||||
{
|
||||
SHADER_BUFFER *buffer = ins->ctx->buffer;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
const char *tex_type;
|
||||
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
|
||||
|
|
|
@ -633,7 +633,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
|
|||
|
||||
/* Save sampler usage token */
|
||||
} else if (WINED3DSPR_SAMPLER == regtype)
|
||||
reg_maps->samplers[regnum] = usage;
|
||||
reg_maps->sampler_type[regnum] = usage & WINED3DSP_TEXTURETYPE_MASK;
|
||||
}
|
||||
else if (ins.handler_idx == WINED3DSIH_DEF)
|
||||
{
|
||||
|
@ -734,7 +734,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
|
|||
DWORD sampler_code = *pToken & WINED3DSP_REGNUM_MASK;
|
||||
|
||||
TRACE("Setting fake 2D sampler for 1.x pixelshader\n");
|
||||
reg_maps->samplers[sampler_code] = (0x1 << 31) | WINED3DSTT_2D;
|
||||
reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
|
||||
|
||||
/* texbem is only valid with < 1.4 pixel shaders */
|
||||
if (ins.handler_idx == WINED3DSIH_TEXBEM
|
||||
|
|
|
@ -4208,12 +4208,13 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
|
|||
}
|
||||
|
||||
static void device_map_psamplers(IWineD3DDeviceImpl *This) {
|
||||
const DWORD *sampler_tokens =
|
||||
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.samplers;
|
||||
const WINED3DSAMPLER_TEXTURE_TYPE *sampler_type =
|
||||
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.sampler_type;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
|
||||
if (sampler_tokens[i] && This->texUnitMap[i] != i) {
|
||||
if (sampler_type[i] && This->texUnitMap[i] != i)
|
||||
{
|
||||
device_map_stage(This, i, i);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
|
||||
if (i < MAX_TEXTURES) {
|
||||
|
@ -4250,9 +4251,9 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshad
|
|||
}
|
||||
|
||||
static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
|
||||
const DWORD *vshader_sampler_tokens =
|
||||
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.samplers;
|
||||
const DWORD *pshader_sampler_tokens = NULL;
|
||||
const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type =
|
||||
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type;
|
||||
const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL;
|
||||
int start = GL_LIMITS(combined_samplers) - 1;
|
||||
int i;
|
||||
|
||||
|
@ -4261,12 +4262,13 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
|
|||
|
||||
/* Note that we only care if a sampler is sampled or not, not the sampler's specific type.
|
||||
* Otherwise we'd need to call shader_update_samplers() here for 1.x pixelshaders. */
|
||||
pshader_sampler_tokens = pshader->baseShader.reg_maps.samplers;
|
||||
pshader_sampler_type = pshader->baseShader.reg_maps.sampler_type;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
|
||||
int vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
|
||||
if (vshader_sampler_tokens[i]) {
|
||||
if (vshader_sampler_type[i])
|
||||
{
|
||||
if (This->texUnitMap[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
|
||||
{
|
||||
/* Already mapped somewhere */
|
||||
|
@ -4274,7 +4276,8 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
|
|||
}
|
||||
|
||||
while (start >= 0) {
|
||||
if (device_unit_free_for_vs(This, pshader_sampler_tokens, vshader_sampler_tokens, start)) {
|
||||
if (device_unit_free_for_vs(This, pshader_sampler_type, vshader_sampler_type, start))
|
||||
{
|
||||
device_map_stage(This, vsampler_idx, start);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(vsampler_idx));
|
||||
|
||||
|
|
|
@ -834,11 +834,10 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
|
|||
|
||||
/* Declare texture samplers */
|
||||
for (i = 0; i < This->baseShader.limits.sampler; i++) {
|
||||
if (reg_maps->samplers[i]) {
|
||||
|
||||
DWORD stype = reg_maps->samplers[i] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
switch (stype) {
|
||||
|
||||
if (reg_maps->sampler_type[i])
|
||||
{
|
||||
switch (reg_maps->sampler_type[i])
|
||||
{
|
||||
case WINED3DSTT_1D:
|
||||
shader_addline(buffer, "uniform sampler1D %csampler%u;\n", prefix, i);
|
||||
break;
|
||||
|
@ -867,7 +866,7 @@ static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const s
|
|||
break;
|
||||
default:
|
||||
shader_addline(buffer, "uniform unsupported_sampler %csampler%u;\n", prefix, i);
|
||||
FIXME("Unrecognized sampler type: %#x\n", stype);
|
||||
FIXME("Unrecognized sampler type: %#x\n", reg_maps->sampler_type[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2440,7 +2439,7 @@ static void pshader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
|||
DWORD shader_version = ins->ctx->reg_maps->shader_version;
|
||||
glsl_sample_function_t sample_function;
|
||||
DWORD sample_flags = 0;
|
||||
DWORD sampler_type;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type;
|
||||
DWORD sampler_idx;
|
||||
DWORD mask = 0, swizzle;
|
||||
|
||||
|
@ -2448,7 +2447,7 @@ static void pshader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
|||
* 2.0+: Use provided sampler source. */
|
||||
if (shader_version < WINED3DPS_VERSION(2,0)) sampler_idx = ins->dst[0].register_idx;
|
||||
else sampler_idx = ins->src[1].register_idx;
|
||||
sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
|
||||
if (shader_version < WINED3DPS_VERSION(1,4))
|
||||
{
|
||||
|
@ -2533,7 +2532,7 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
|
|||
DWORD swizzle = ins->src[1].swizzle;
|
||||
|
||||
sampler_idx = ins->src[1].register_idx;
|
||||
sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
if(deviceImpl->stateBlock->textures[sampler_idx] &&
|
||||
IWineD3DBaseTexture_GetTextureDimensions(deviceImpl->stateBlock->textures[sampler_idx]) == GL_TEXTURE_RECTANGLE_ARB) {
|
||||
sample_flags |= WINED3D_GLSL_SAMPLE_RECT;
|
||||
|
@ -2608,7 +2607,7 @@ static void pshader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins)
|
|||
glsl_sample_function_t sample_function;
|
||||
DWORD sampler_idx = ins->dst[0].register_idx;
|
||||
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
UINT mask_size;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
|
||||
|
@ -2735,7 +2734,7 @@ static void pshader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins
|
|||
DWORD reg = ins->dst[0].register_idx;
|
||||
SHADER_BUFFER *buffer = ins->ctx->buffer;
|
||||
glsl_src_param_t src0_param;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
|
||||
|
@ -2756,7 +2755,7 @@ static void pshader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins
|
|||
DWORD reg = ins->dst[0].register_idx;
|
||||
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
|
||||
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
|
||||
|
@ -2801,7 +2800,7 @@ static void pshader_glsl_texm3x3spec(const struct wined3d_shader_instruction *in
|
|||
glsl_src_param_t src1_param;
|
||||
SHADER_BUFFER *buffer = ins->ctx->buffer;
|
||||
SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
|
||||
DWORD stype = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE stype = ins->ctx->reg_maps->sampler_type[reg];
|
||||
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
|
@ -2832,7 +2831,7 @@ static void pshader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *i
|
|||
SHADER_PARSE_STATE* current_state = &shader->baseShader.parse_state;
|
||||
glsl_src_param_t src0_param;
|
||||
DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[reg] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[reg];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], src_mask, &src0_param);
|
||||
|
@ -2864,7 +2863,7 @@ static void pshader_glsl_texbem(const struct wined3d_shader_instruction *ins)
|
|||
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
|
||||
glsl_sample_function_t sample_function;
|
||||
glsl_src_param_t coord_param;
|
||||
DWORD sampler_type;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type;
|
||||
DWORD sampler_idx;
|
||||
DWORD mask;
|
||||
DWORD flags;
|
||||
|
@ -2873,7 +2872,7 @@ static void pshader_glsl_texbem(const struct wined3d_shader_instruction *ins)
|
|||
sampler_idx = ins->dst[0].register_idx;
|
||||
flags = deviceImpl->stateBlock->textureState[sampler_idx][WINED3DTSS_TEXTURETRANSFORMFLAGS];
|
||||
|
||||
sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
/* Dependent read, not valid with conditional NP2 */
|
||||
shader_glsl_get_sample_function(sampler_type, 0, &sample_function);
|
||||
mask = sample_function.coord_mask;
|
||||
|
@ -2936,7 +2935,7 @@ static void pshader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins)
|
|||
{
|
||||
glsl_src_param_t src0_param;
|
||||
DWORD sampler_idx = ins->dst[0].register_idx;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param);
|
||||
|
@ -2952,7 +2951,7 @@ static void pshader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins)
|
|||
{
|
||||
glsl_src_param_t src0_param;
|
||||
DWORD sampler_idx = ins->dst[0].register_idx;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_ALL, &src0_param);
|
||||
|
@ -2968,7 +2967,7 @@ static void pshader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins
|
|||
{
|
||||
glsl_src_param_t src0_param;
|
||||
DWORD sampler_idx = ins->dst[0].register_idx;
|
||||
DWORD sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
||||
glsl_sample_function_t sample_function;
|
||||
|
||||
/* Dependent read, not valid with conditional NP2 */
|
||||
|
|
|
@ -374,7 +374,7 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
|
|||
static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
|
||||
{
|
||||
DWORD shader_version = reg_maps->shader_version;
|
||||
DWORD *samplers = reg_maps->samplers;
|
||||
WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type;
|
||||
unsigned int i;
|
||||
|
||||
if (WINED3DSHADER_VERSION_MAJOR(shader_version) != 1) return;
|
||||
|
@ -382,12 +382,12 @@ static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD
|
|||
for (i = 0; i < max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS); ++i)
|
||||
{
|
||||
/* We don't sample from this sampler */
|
||||
if (!samplers[i]) continue;
|
||||
if (!sampler_type[i]) continue;
|
||||
|
||||
if (!textures[i])
|
||||
{
|
||||
ERR("No texture bound to sampler %u, using 2D\n", i);
|
||||
samplers[i] = (0x1 << 31) | WINED3DSTT_2D;
|
||||
sampler_type[i] = WINED3DSTT_2D;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -397,21 +397,21 @@ static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD
|
|||
case GL_TEXTURE_2D:
|
||||
/* We have to select between texture rectangles and 2D textures later because 2.0 and
|
||||
* 3.0 shaders only have WINED3DSTT_2D as well */
|
||||
samplers[i] = (1 << 31) | WINED3DSTT_2D;
|
||||
sampler_type[i] = WINED3DSTT_2D;
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_3D:
|
||||
samplers[i] = (1 << 31) | WINED3DSTT_VOLUME;
|
||||
sampler_type[i] = WINED3DSTT_VOLUME;
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||
samplers[i] = (1 << 31) | WINED3DSTT_CUBE;
|
||||
sampler_type[i] = WINED3DSTT_CUBE;
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unrecognized texture type %#x, using 2D\n",
|
||||
IWineD3DBaseTexture_GetTextureDimensions(textures[i]));
|
||||
samplers[i] = (0x1 << 31) | WINED3DSTT_2D;
|
||||
sampler_type[i] = WINED3DSTT_2D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
|
|||
args->np2_fixup = 0;
|
||||
|
||||
for(i = 0; i < MAX_FRAGMENT_SAMPLERS; i++) {
|
||||
if(shader->baseShader.reg_maps.samplers[i] == 0) continue;
|
||||
if (!shader->baseShader.reg_maps.sampler_type[i]) continue;
|
||||
tex = (IWineD3DBaseTextureImpl *) stateblock->textures[i];
|
||||
if(!tex) {
|
||||
args->color_fixup[i] = COLOR_FIXUP_IDENTITY;
|
||||
|
|
|
@ -416,9 +416,7 @@ typedef struct shader_reg_maps
|
|||
WORD integer_constants; /* MAX_CONST_I, 16 */
|
||||
WORD boolean_constants; /* MAX_CONST_B, 16 */
|
||||
|
||||
/* Sampler usage tokens
|
||||
* Use 0 as default (bit 31 is always 1 on a valid token) */
|
||||
DWORD samplers[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
|
||||
WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
|
||||
BOOL bumpmat[MAX_TEXTURES], luminanceparams[MAX_TEXTURES];
|
||||
char usesnrm, vpos, usesdsy;
|
||||
char usesrelconstF;
|
||||
|
|
Loading…
Reference in New Issue