wined3d: Store resource types instead of sampler types in struct wined3d_shader_reg_maps.
The difference doesn't really matter for SM1-3 since resources and samplers are always tied together, but in SM4 they're separate.
This commit is contained in:
parent
5ccda82acc
commit
f5cef43738
|
@ -1390,8 +1390,8 @@ static const char *shader_arb_get_modifier(const struct wined3d_shader_instructi
|
||||||
static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD sampler_idx,
|
static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD sampler_idx,
|
||||||
const char *dst_str, const char *coord_reg, WORD flags, const char *dsx, const char *dsy)
|
const char *dst_str, const char *coord_reg, WORD flags, const char *dsx, const char *dsy)
|
||||||
{
|
{
|
||||||
|
enum wined3d_shader_resource_type resource_type = ins->ctx->reg_maps->resource_type[sampler_idx];
|
||||||
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
|
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
|
||||||
DWORD sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
|
||||||
const char *tex_type;
|
const char *tex_type;
|
||||||
BOOL np2_fixup = FALSE;
|
BOOL np2_fixup = FALSE;
|
||||||
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
|
struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
|
||||||
|
@ -1404,12 +1404,13 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
|
||||||
/* D3D vertex shader sampler IDs are vertex samplers(0-3), not global d3d samplers */
|
/* D3D vertex shader sampler IDs are vertex samplers(0-3), not global d3d samplers */
|
||||||
if(!pshader) sampler_idx += MAX_FRAGMENT_SAMPLERS;
|
if(!pshader) sampler_idx += MAX_FRAGMENT_SAMPLERS;
|
||||||
|
|
||||||
switch(sampler_type) {
|
switch (resource_type)
|
||||||
case WINED3DSTT_1D:
|
{
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_1D:
|
||||||
tex_type = "1D";
|
tex_type = "1D";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DSTT_2D:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
||||||
shader = ins->ctx->shader;
|
shader = ins->ctx->shader;
|
||||||
device = shader->device;
|
device = shader->device;
|
||||||
gl_info = &device->adapter->gl_info;
|
gl_info = &device->adapter->gl_info;
|
||||||
|
@ -1429,16 +1430,16 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DSTT_VOLUME:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
||||||
tex_type = "3D";
|
tex_type = "3D";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DSTT_CUBE:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
||||||
tex_type = "CUBE";
|
tex_type = "CUBE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Unexpected texture type %d\n", sampler_type);
|
ERR("Unexpected resource type %#x.\n", resource_type);
|
||||||
tex_type = "";
|
tex_type = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4376,7 +4377,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(struct wined3d_shader *sh
|
||||||
|
|
||||||
shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
|
shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
|
||||||
|
|
||||||
pixelshader_update_samplers(shader, args->super.tex_types);
|
pixelshader_update_resource_types(shader, args->super.tex_types);
|
||||||
|
|
||||||
if (!shader_buffer_init(&buffer))
|
if (!shader_buffer_init(&buffer))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2585,14 +2585,14 @@ static void context_map_fixed_function_samplers(struct wined3d_context *context,
|
||||||
|
|
||||||
static void context_map_psamplers(struct wined3d_context *context, const struct wined3d_state *state)
|
static void context_map_psamplers(struct wined3d_context *context, const struct wined3d_state *state)
|
||||||
{
|
{
|
||||||
const enum wined3d_sampler_texture_type *sampler_type =
|
const enum wined3d_shader_resource_type *resource_type =
|
||||||
state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type;
|
state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.resource_type;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
||||||
|
|
||||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
||||||
{
|
{
|
||||||
if (sampler_type[i] && context->tex_unit_map[i] != i)
|
if (resource_type[i] && context->tex_unit_map[i] != i)
|
||||||
{
|
{
|
||||||
context_map_stage(context, i, i);
|
context_map_stage(context, i, i);
|
||||||
context_invalidate_state(context, STATE_SAMPLER(i));
|
context_invalidate_state(context, STATE_SAMPLER(i));
|
||||||
|
@ -2603,8 +2603,8 @@ static void context_map_psamplers(struct wined3d_context *context, const struct
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL context_unit_free_for_vs(const struct wined3d_context *context,
|
static BOOL context_unit_free_for_vs(const struct wined3d_context *context,
|
||||||
const enum wined3d_sampler_texture_type *pshader_sampler_tokens,
|
const enum wined3d_shader_resource_type *ps_resource_types,
|
||||||
const enum wined3d_sampler_texture_type *vshader_sampler_tokens, DWORD unit)
|
const enum wined3d_shader_resource_type *vs_resource_types, DWORD unit)
|
||||||
{
|
{
|
||||||
DWORD current_mapping = context->rev_tex_unit_map[unit];
|
DWORD current_mapping = context->rev_tex_unit_map[unit];
|
||||||
|
|
||||||
|
@ -2616,39 +2616,39 @@ static BOOL context_unit_free_for_vs(const struct wined3d_context *context,
|
||||||
{
|
{
|
||||||
/* Used by a fragment sampler */
|
/* Used by a fragment sampler */
|
||||||
|
|
||||||
if (!pshader_sampler_tokens)
|
if (!ps_resource_types)
|
||||||
{
|
{
|
||||||
/* No pixel shader, check fixed function */
|
/* No pixel shader, check fixed function */
|
||||||
return current_mapping >= MAX_TEXTURES || !(context->fixed_function_usage_map & (1 << current_mapping));
|
return current_mapping >= MAX_TEXTURES || !(context->fixed_function_usage_map & (1 << current_mapping));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pixel shader, check the shader's sampler map */
|
/* Pixel shader, check the shader's sampler map */
|
||||||
return !pshader_sampler_tokens[current_mapping];
|
return !ps_resource_types[current_mapping];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used by a vertex sampler */
|
/* Used by a vertex sampler */
|
||||||
return !vshader_sampler_tokens[current_mapping - MAX_FRAGMENT_SAMPLERS];
|
return !vs_resource_types[current_mapping - MAX_FRAGMENT_SAMPLERS];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void context_map_vsamplers(struct wined3d_context *context, BOOL ps, const struct wined3d_state *state)
|
static void context_map_vsamplers(struct wined3d_context *context, BOOL ps, const struct wined3d_state *state)
|
||||||
{
|
{
|
||||||
const enum wined3d_sampler_texture_type *vshader_sampler_type =
|
const enum wined3d_shader_resource_type *vs_resource_type =
|
||||||
state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.sampler_type;
|
state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.resource_type;
|
||||||
const enum wined3d_sampler_texture_type *pshader_sampler_type = NULL;
|
const enum wined3d_shader_resource_type *ps_resource_type = NULL;
|
||||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||||
int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
|
int start = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers) - 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Note that we only care if a resource is used or not, not the
|
||||||
|
* resource's specific type. Otherwise we'd need to call
|
||||||
|
* shader_update_samplers() here for 1.x pixelshaders. */
|
||||||
if (ps)
|
if (ps)
|
||||||
{
|
ps_resource_type = state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.resource_type;
|
||||||
/* 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_type = state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
|
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
|
||||||
|
{
|
||||||
DWORD vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
|
DWORD vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
|
||||||
if (vshader_sampler_type[i])
|
if (vs_resource_type[i])
|
||||||
{
|
{
|
||||||
if (context->tex_unit_map[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
|
if (context->tex_unit_map[vsampler_idx] != WINED3D_UNMAPPED_STAGE)
|
||||||
{
|
{
|
||||||
|
@ -2658,7 +2658,7 @@ static void context_map_vsamplers(struct wined3d_context *context, BOOL ps, cons
|
||||||
|
|
||||||
while (start >= 0)
|
while (start >= 0)
|
||||||
{
|
{
|
||||||
if (context_unit_free_for_vs(context, pshader_sampler_type, vshader_sampler_type, start))
|
if (context_unit_free_for_vs(context, ps_resource_type, vs_resource_type, start))
|
||||||
{
|
{
|
||||||
context_map_stage(context, vsampler_idx, start);
|
context_map_stage(context, vsampler_idx, start);
|
||||||
context_invalidate_state(context, STATE_SAMPLER(vsampler_idx));
|
context_invalidate_state(context, STATE_SAMPLER(vsampler_idx));
|
||||||
|
@ -2930,7 +2930,7 @@ static void context_preload_textures(struct wined3d_context *context, const stru
|
||||||
{
|
{
|
||||||
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
|
for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i)
|
||||||
{
|
{
|
||||||
if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.sampler_type[i])
|
if (state->shader[WINED3D_SHADER_TYPE_VERTEX]->reg_maps.resource_type[i])
|
||||||
context_preload_texture(context, state, MAX_FRAGMENT_SAMPLERS + i);
|
context_preload_texture(context, state, MAX_FRAGMENT_SAMPLERS + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2939,7 +2939,7 @@ static void context_preload_textures(struct wined3d_context *context, const stru
|
||||||
{
|
{
|
||||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
||||||
{
|
{
|
||||||
if (state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.sampler_type[i])
|
if (state->shader[WINED3D_SHADER_TYPE_PIXEL]->reg_maps.resource_type[i])
|
||||||
context_preload_texture(context, state, i);
|
context_preload_texture(context, state, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1064,20 +1064,22 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
|
||||||
/* Declare texture samplers */
|
/* Declare texture samplers */
|
||||||
for (i = 0; i < shader->limits->sampler; ++i)
|
for (i = 0; i < shader->limits->sampler; ++i)
|
||||||
{
|
{
|
||||||
if (reg_maps->sampler_type[i])
|
BOOL shadow_sampler, tex_rect;
|
||||||
{
|
|
||||||
BOOL shadow_sampler = version->type == WINED3D_SHADER_TYPE_PIXEL && (ps_args->shadow & (1 << i));
|
|
||||||
BOOL tex_rect;
|
|
||||||
|
|
||||||
switch (reg_maps->sampler_type[i])
|
if (!reg_maps->resource_type[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
shadow_sampler = version->type == WINED3D_SHADER_TYPE_PIXEL && (ps_args->shadow & (1 << i));
|
||||||
|
switch (reg_maps->resource_type[i])
|
||||||
{
|
{
|
||||||
case WINED3DSTT_1D:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_1D:
|
||||||
if (shadow_sampler)
|
if (shadow_sampler)
|
||||||
shader_addline(buffer, "uniform sampler1DShadow %s_sampler%u;\n", prefix, i);
|
shader_addline(buffer, "uniform sampler1DShadow %s_sampler%u;\n", prefix, i);
|
||||||
else
|
else
|
||||||
shader_addline(buffer, "uniform sampler1D %s_sampler%u;\n", prefix, i);
|
shader_addline(buffer, "uniform sampler1D %s_sampler%u;\n", prefix, i);
|
||||||
break;
|
break;
|
||||||
case WINED3DSTT_2D:
|
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
||||||
tex_rect = version->type == WINED3D_SHADER_TYPE_PIXEL && (ps_args->np2_fixup & (1 << i));
|
tex_rect = version->type == WINED3D_SHADER_TYPE_PIXEL && (ps_args->np2_fixup & (1 << i));
|
||||||
tex_rect = tex_rect && gl_info->supported[ARB_TEXTURE_RECTANGLE];
|
tex_rect = tex_rect && gl_info->supported[ARB_TEXTURE_RECTANGLE];
|
||||||
if (shadow_sampler)
|
if (shadow_sampler)
|
||||||
|
@ -1095,23 +1097,25 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
|
||||||
shader_addline(buffer, "uniform sampler2D %s_sampler%u;\n", prefix, i);
|
shader_addline(buffer, "uniform sampler2D %s_sampler%u;\n", prefix, i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WINED3DSTT_CUBE:
|
|
||||||
if (shadow_sampler)
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
||||||
FIXME("Unsupported Cube shadow sampler.\n");
|
|
||||||
shader_addline(buffer, "uniform samplerCube %s_sampler%u;\n", prefix, i);
|
|
||||||
break;
|
|
||||||
case WINED3DSTT_VOLUME:
|
|
||||||
if (shadow_sampler)
|
if (shadow_sampler)
|
||||||
FIXME("Unsupported 3D shadow sampler.\n");
|
FIXME("Unsupported 3D shadow sampler.\n");
|
||||||
shader_addline(buffer, "uniform sampler3D %s_sampler%u;\n", prefix, i);
|
shader_addline(buffer, "uniform sampler3D %s_sampler%u;\n", prefix, i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
||||||
|
if (shadow_sampler)
|
||||||
|
FIXME("Unsupported Cube shadow sampler.\n");
|
||||||
|
shader_addline(buffer, "uniform samplerCube %s_sampler%u;\n", prefix, i);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
shader_addline(buffer, "uniform unsupported_sampler %s_sampler%u;\n", prefix, i);
|
shader_addline(buffer, "uniform unsupported_sampler %s_sampler%u;\n", prefix, i);
|
||||||
FIXME("Unrecognized sampler type: %#x\n", reg_maps->sampler_type[i]);
|
FIXME("Unhandled resource type %#x.\n", reg_maps->resource_type[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Declare uniforms for NP2 texcoord fixup:
|
/* Declare uniforms for NP2 texcoord fixup:
|
||||||
* This is NOT done inside the loop that declares the texture samplers
|
* This is NOT done inside the loop that declares the texture samplers
|
||||||
|
@ -1130,18 +1134,17 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
|
||||||
|
|
||||||
for (i = 0; i < shader->limits->sampler; ++i)
|
for (i = 0; i < shader->limits->sampler; ++i)
|
||||||
{
|
{
|
||||||
if (reg_maps->sampler_type[i])
|
if (!reg_maps->resource_type[i] || !(ps_args->np2_fixup & (1 << i)))
|
||||||
{
|
continue;
|
||||||
if (!(ps_args->np2_fixup & (1 << i))) continue;
|
|
||||||
|
|
||||||
if (WINED3DSTT_2D != reg_maps->sampler_type[i]) {
|
if (reg_maps->resource_type[i] != WINED3D_SHADER_RESOURCE_TEXTURE_2D)
|
||||||
|
{
|
||||||
FIXME("Non-2D texture is flagged for NP2 texcoord fixup.\n");
|
FIXME("Non-2D texture is flagged for NP2 texcoord fixup.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixup->idx[i] = cur++;
|
fixup->idx[i] = cur++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fixup->num_consts = (cur + 1) >> 1;
|
fixup->num_consts = (cur + 1) >> 1;
|
||||||
fixup->active = ps_args->np2_fixup;
|
fixup->active = ps_args->np2_fixup;
|
||||||
|
@ -1885,20 +1888,21 @@ static const char *shader_glsl_get_rel_op(enum wined3d_shader_rel_op op)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shader_glsl_get_sample_function(const struct wined3d_shader_context *ctx,
|
static void shader_glsl_get_sample_function(const struct wined3d_shader_context *ctx,
|
||||||
DWORD sampler_idx, DWORD flags, struct glsl_sample_function *sample_function)
|
DWORD resource_idx, DWORD flags, struct glsl_sample_function *sample_function)
|
||||||
{
|
{
|
||||||
enum wined3d_sampler_texture_type sampler_type = ctx->reg_maps->sampler_type[sampler_idx];
|
enum wined3d_shader_resource_type resource_type = ctx->reg_maps->resource_type[resource_idx];
|
||||||
const struct wined3d_gl_info *gl_info = ctx->gl_info;
|
const struct wined3d_gl_info *gl_info = ctx->gl_info;
|
||||||
BOOL shadow = ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL
|
BOOL shadow = ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL
|
||||||
&& (((const struct shader_glsl_ctx_priv *)ctx->backend_data)->cur_ps_args->shadow & (1 << sampler_idx));
|
&& (((const struct shader_glsl_ctx_priv *)ctx->backend_data)->cur_ps_args->shadow & (1 << resource_idx));
|
||||||
BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED;
|
BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED;
|
||||||
BOOL texrect = flags & WINED3D_GLSL_SAMPLE_NPOT && gl_info->supported[ARB_TEXTURE_RECTANGLE];
|
BOOL texrect = flags & WINED3D_GLSL_SAMPLE_NPOT && gl_info->supported[ARB_TEXTURE_RECTANGLE];
|
||||||
BOOL lod = flags & WINED3D_GLSL_SAMPLE_LOD;
|
BOOL lod = flags & WINED3D_GLSL_SAMPLE_LOD;
|
||||||
BOOL grad = flags & WINED3D_GLSL_SAMPLE_GRAD;
|
BOOL grad = flags & WINED3D_GLSL_SAMPLE_GRAD;
|
||||||
|
|
||||||
/* Note that there's no such thing as a projected cube texture. */
|
/* Note that there's no such thing as a projected cube texture. */
|
||||||
switch(sampler_type) {
|
switch (resource_type)
|
||||||
case WINED3DSTT_1D:
|
{
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_1D:
|
||||||
if (shadow)
|
if (shadow)
|
||||||
{
|
{
|
||||||
if (lod)
|
if (lod)
|
||||||
|
@ -1949,7 +1953,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DSTT_2D:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
||||||
if (shadow)
|
if (shadow)
|
||||||
{
|
{
|
||||||
if (texrect)
|
if (texrect)
|
||||||
|
@ -2052,40 +2056,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3DSTT_CUBE:
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
||||||
if (shadow)
|
|
||||||
{
|
|
||||||
FIXME("Unsupported Cube shadow function.\n");
|
|
||||||
sample_function->name = "unsupportedCubeShadow";
|
|
||||||
sample_function->coord_mask = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lod)
|
|
||||||
{
|
|
||||||
sample_function->name = "textureCubeLod";
|
|
||||||
}
|
|
||||||
else if (grad)
|
|
||||||
{
|
|
||||||
if (gl_info->supported[EXT_GPU_SHADER4])
|
|
||||||
sample_function->name = "textureCubeGrad";
|
|
||||||
else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
|
|
||||||
sample_function->name = "textureCubeGradARB";
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FIXME("Unsupported Cube grad function.\n");
|
|
||||||
sample_function->name = "unsupportedCubeGrad";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample_function->name = "textureCube";
|
|
||||||
}
|
|
||||||
sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WINED3DSTT_VOLUME:
|
|
||||||
if (shadow)
|
if (shadow)
|
||||||
{
|
{
|
||||||
FIXME("Unsupported 3D shadow function.\n");
|
FIXME("Unsupported 3D shadow function.\n");
|
||||||
|
@ -2118,10 +2089,43 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
||||||
|
if (shadow)
|
||||||
|
{
|
||||||
|
FIXME("Unsupported Cube shadow function.\n");
|
||||||
|
sample_function->name = "unsupportedCubeShadow";
|
||||||
|
sample_function->coord_mask = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lod)
|
||||||
|
{
|
||||||
|
sample_function->name = "textureCubeLod";
|
||||||
|
}
|
||||||
|
else if (grad)
|
||||||
|
{
|
||||||
|
if (gl_info->supported[EXT_GPU_SHADER4])
|
||||||
|
sample_function->name = "textureCubeGrad";
|
||||||
|
else if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
|
||||||
|
sample_function->name = "textureCubeGradARB";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("Unsupported Cube grad function.\n");
|
||||||
|
sample_function->name = "unsupportedCubeGrad";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sample_function->name = "textureCube";
|
||||||
|
}
|
||||||
|
sample_function->coord_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sample_function->name = "";
|
sample_function->name = "";
|
||||||
sample_function->coord_mask = 0;
|
sample_function->coord_mask = 0;
|
||||||
FIXME("Unrecognized sampler type: %#x;\n", sampler_type);
|
FIXME("Unhandled resource type %#x.\n", resource_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3449,25 +3453,25 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
||||||
ins->ctx->reg_maps->shader_version.minor);
|
ins->ctx->reg_maps->shader_version.minor);
|
||||||
struct glsl_sample_function sample_function;
|
struct glsl_sample_function sample_function;
|
||||||
DWORD sample_flags = 0;
|
DWORD sample_flags = 0;
|
||||||
DWORD sampler_idx;
|
DWORD resource_idx;
|
||||||
DWORD mask = 0, swizzle;
|
DWORD mask = 0, swizzle;
|
||||||
const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
|
const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
|
||||||
|
|
||||||
/* 1.0-1.4: Use destination register as sampler source.
|
/* 1.0-1.4: Use destination register as sampler source.
|
||||||
* 2.0+: Use provided sampler source. */
|
* 2.0+: Use provided sampler source. */
|
||||||
if (shader_version < WINED3D_SHADER_VERSION(2,0))
|
if (shader_version < WINED3D_SHADER_VERSION(2,0))
|
||||||
sampler_idx = ins->dst[0].reg.idx[0].offset;
|
resource_idx = ins->dst[0].reg.idx[0].offset;
|
||||||
else
|
else
|
||||||
sampler_idx = ins->src[1].reg.idx[0].offset;
|
resource_idx = ins->src[1].reg.idx[0].offset;
|
||||||
|
|
||||||
if (shader_version < WINED3D_SHADER_VERSION(1,4))
|
if (shader_version < WINED3D_SHADER_VERSION(1,4))
|
||||||
{
|
{
|
||||||
DWORD flags = (priv->cur_ps_args->tex_transform >> sampler_idx * WINED3D_PSARGS_TEXTRANSFORM_SHIFT)
|
DWORD flags = (priv->cur_ps_args->tex_transform >> resource_idx * WINED3D_PSARGS_TEXTRANSFORM_SHIFT)
|
||||||
& WINED3D_PSARGS_TEXTRANSFORM_MASK;
|
& WINED3D_PSARGS_TEXTRANSFORM_MASK;
|
||||||
enum wined3d_sampler_texture_type sampler_type = ins->ctx->reg_maps->sampler_type[sampler_idx];
|
enum wined3d_shader_resource_type resource_type = ins->ctx->reg_maps->resource_type[resource_idx];
|
||||||
|
|
||||||
/* Projected cube textures don't make a lot of sense, the resulting coordinates stay the same. */
|
/* Projected cube textures don't make a lot of sense, the resulting coordinates stay the same. */
|
||||||
if (flags & WINED3D_PSARGS_PROJECTED && sampler_type != WINED3DSTT_CUBE)
|
if (flags & WINED3D_PSARGS_PROJECTED && resource_type != WINED3D_SHADER_RESOURCE_TEXTURE_CUBE)
|
||||||
{
|
{
|
||||||
sample_flags |= WINED3D_GLSL_SAMPLE_PROJECTED;
|
sample_flags |= WINED3D_GLSL_SAMPLE_PROJECTED;
|
||||||
switch (flags & ~WINED3D_PSARGS_PROJECTED)
|
switch (flags & ~WINED3D_PSARGS_PROJECTED)
|
||||||
|
@ -3503,7 +3507,7 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((ins->flags & WINED3DSI_TEXLD_PROJECT)
|
if ((ins->flags & WINED3DSI_TEXLD_PROJECT)
|
||||||
&& ins->ctx->reg_maps->sampler_type[sampler_idx] != WINED3DSTT_CUBE)
|
&& ins->ctx->reg_maps->resource_type[resource_idx] != WINED3D_SHADER_RESOURCE_TEXTURE_CUBE)
|
||||||
{
|
{
|
||||||
/* ps 2.0 texldp instruction always divides by the fourth component. */
|
/* ps 2.0 texldp instruction always divides by the fourth component. */
|
||||||
sample_flags |= WINED3D_GLSL_SAMPLE_PROJECTED;
|
sample_flags |= WINED3D_GLSL_SAMPLE_PROJECTED;
|
||||||
|
@ -3511,10 +3515,10 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->cur_ps_args->np2_fixup & (1 << sampler_idx))
|
if (priv->cur_ps_args->np2_fixup & (1 << resource_idx))
|
||||||
sample_flags |= WINED3D_GLSL_SAMPLE_NPOT;
|
sample_flags |= WINED3D_GLSL_SAMPLE_NPOT;
|
||||||
|
|
||||||
shader_glsl_get_sample_function(ins->ctx, sampler_idx, sample_flags, &sample_function);
|
shader_glsl_get_sample_function(ins->ctx, resource_idx, sample_flags, &sample_function);
|
||||||
mask |= sample_function.coord_mask;
|
mask |= sample_function.coord_mask;
|
||||||
|
|
||||||
if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE;
|
if (shader_version < WINED3D_SHADER_VERSION(2,0)) swizzle = WINED3DSP_NOSWIZZLE;
|
||||||
|
@ -3526,8 +3530,8 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
||||||
{
|
{
|
||||||
char coord_mask[6];
|
char coord_mask[6];
|
||||||
shader_glsl_write_mask_to_str(mask, coord_mask);
|
shader_glsl_write_mask_to_str(mask, coord_mask);
|
||||||
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, swizzle, NULL, NULL, NULL,
|
shader_glsl_gen_sample_code(ins, resource_idx, &sample_function, swizzle, NULL, NULL, NULL,
|
||||||
"T%u%s", sampler_idx, coord_mask);
|
"T%u%s", resource_idx, coord_mask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3537,10 +3541,10 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
|
||||||
{
|
{
|
||||||
struct glsl_src_param bias;
|
struct glsl_src_param bias;
|
||||||
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &bias);
|
shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &bias);
|
||||||
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, swizzle, NULL, NULL, bias.param_str,
|
shader_glsl_gen_sample_code(ins, resource_idx, &sample_function, swizzle, NULL, NULL, bias.param_str,
|
||||||
"%s", coord_param.param_str);
|
"%s", coord_param.param_str);
|
||||||
} else {
|
} else {
|
||||||
shader_glsl_gen_sample_code(ins, sampler_idx, &sample_function, swizzle, NULL, NULL, NULL,
|
shader_glsl_gen_sample_code(ins, resource_idx, &sample_function, swizzle, NULL, NULL, NULL,
|
||||||
"%s", coord_param.param_str);
|
"%s", coord_param.param_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4677,7 +4681,7 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
|
||||||
memset(np2fixup, 0, sizeof(*np2fixup));
|
memset(np2fixup, 0, sizeof(*np2fixup));
|
||||||
*np2fixup_info = args->np2_fixup ? np2fixup : NULL;
|
*np2fixup_info = args->np2_fixup ? np2fixup : NULL;
|
||||||
|
|
||||||
pixelshader_update_samplers(shader, args->tex_types);
|
pixelshader_update_resource_types(shader, args->tex_types);
|
||||||
|
|
||||||
shader_buffer_clear(buffer);
|
shader_buffer_clear(buffer);
|
||||||
ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);
|
ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);
|
||||||
|
|
|
@ -662,14 +662,13 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
|
||||||
reg_maps->fog = 1;
|
reg_maps->fog = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Save sampler usage token. */
|
|
||||||
case WINED3DSPR_SAMPLER:
|
case WINED3DSPR_SAMPLER:
|
||||||
if (reg_idx >= ARRAY_SIZE(reg_maps->sampler_type))
|
if (reg_idx >= ARRAY_SIZE(reg_maps->resource_type))
|
||||||
{
|
{
|
||||||
ERR("Invalid sampler index %u.\n", reg_idx);
|
ERR("Invalid resource index %u.\n", reg_idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reg_maps->sampler_type[reg_idx] = semantic->sampler_type;
|
reg_maps->resource_type[reg_idx] = semantic->resource_type;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -897,11 +896,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, const st
|
||||||
|| ins.handler_idx == WINED3DSIH_TEXREG2GB
|
|| ins.handler_idx == WINED3DSIH_TEXREG2GB
|
||||||
|| ins.handler_idx == WINED3DSIH_TEXREG2RGB))
|
|| ins.handler_idx == WINED3DSIH_TEXREG2RGB))
|
||||||
{
|
{
|
||||||
/* Fake sampler usage, only set reserved bit and type. */
|
TRACE("Setting fake 2D resource for 1.x pixelshader.\n");
|
||||||
DWORD sampler_code = ins.dst[i].reg.idx[0].offset;
|
reg_maps->resource_type[ins.dst[i].reg.idx[0].offset] = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
|
||||||
|
|
||||||
TRACE("Setting fake 2D sampler for 1.x pixelshader.\n");
|
|
||||||
reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
|
|
||||||
|
|
||||||
/* texbem is only valid with < 1.4 pixel shaders */
|
/* texbem is only valid with < 1.4 pixel shaders */
|
||||||
if (ins.handler_idx == WINED3DSIH_TEXBEM
|
if (ins.handler_idx == WINED3DSIH_TEXBEM
|
||||||
|
@ -1002,12 +998,23 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
|
||||||
|
|
||||||
if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
|
if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
|
||||||
{
|
{
|
||||||
switch (semantic->sampler_type)
|
switch (semantic->resource_type)
|
||||||
{
|
{
|
||||||
case WINED3DSTT_2D: TRACE("_2d"); break;
|
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
|
||||||
case WINED3DSTT_CUBE: TRACE("_cube"); break;
|
TRACE("_2d");
|
||||||
case WINED3DSTT_VOLUME: TRACE("_volume"); break;
|
break;
|
||||||
default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type);
|
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_3D:
|
||||||
|
TRACE("_volume");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE:
|
||||||
|
TRACE("_cube");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
TRACE("_unknown_ttype(0x%08x)", semantic->resource_type);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2125,10 +2132,10 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
|
||||||
|
|
||||||
if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
|
if (!state->shader[WINED3D_SHADER_TYPE_VERTEX])
|
||||||
{
|
{
|
||||||
|
enum wined3d_shader_resource_type resource_type = shader->reg_maps.resource_type[i];
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
|
unsigned int index = state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX];
|
||||||
DWORD max_valid = WINED3D_TTFF_COUNT4;
|
DWORD max_valid = WINED3D_TTFF_COUNT4;
|
||||||
enum wined3d_sampler_texture_type sampler_type = shader->reg_maps.sampler_type[i];
|
|
||||||
|
|
||||||
for (j = 0; j < state->vertex_declaration->element_count; ++j)
|
for (j = 0; j < state->vertex_declaration->element_count; ++j)
|
||||||
{
|
{
|
||||||
|
@ -2148,15 +2155,17 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
|
||||||
tex_transform, max_valid);
|
tex_transform, max_valid);
|
||||||
tex_transform = max_valid;
|
tex_transform = max_valid;
|
||||||
}
|
}
|
||||||
if ((sampler_type == WINED3DSTT_1D && tex_transform > WINED3D_TTFF_COUNT1)
|
if ((resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_1D && tex_transform > WINED3D_TTFF_COUNT1)
|
||||||
|| (sampler_type == WINED3DSTT_2D && tex_transform > WINED3D_TTFF_COUNT2)
|
|| (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D
|
||||||
|| (sampler_type == WINED3DSTT_VOLUME && tex_transform > WINED3D_TTFF_COUNT3))
|
&& tex_transform > WINED3D_TTFF_COUNT2)
|
||||||
|
|| (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_3D
|
||||||
|
&& tex_transform > WINED3D_TTFF_COUNT3))
|
||||||
tex_transform |= WINED3D_PSARGS_PROJECTED;
|
tex_transform |= WINED3D_PSARGS_PROJECTED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN("Application requested projected texture with unsuitable texture coordinates.\n");
|
WARN("Application requested projected texture with unsuitable texture coordinates.\n");
|
||||||
WARN("(texture unit %u, transform flags %#x, sampler type %u).\n",
|
WARN("(texture unit %u, transform flags %#x, sampler type %u).\n",
|
||||||
i, tex_transform, sampler_type);
|
i, tex_transform, resource_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2173,7 +2182,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
|
||||||
{
|
{
|
||||||
const struct wined3d_texture *texture = state->textures[i];
|
const struct wined3d_texture *texture = state->textures[i];
|
||||||
|
|
||||||
if (!shader->reg_maps.sampler_type[i])
|
if (!shader->reg_maps.resource_type[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Treat unbound textures as 2D. The dummy texture will provide
|
/* Treat unbound textures as 2D. The dummy texture will provide
|
||||||
|
@ -2202,7 +2211,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3
|
||||||
|
|
||||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
|
||||||
{
|
{
|
||||||
if (!shader->reg_maps.sampler_type[i])
|
if (!shader->reg_maps.resource_type[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
texture = state->textures[i];
|
texture = state->textures[i];
|
||||||
|
@ -2370,10 +2379,10 @@ static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_de
|
||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pixelshader_update_samplers(struct wined3d_shader *shader, WORD tex_types)
|
void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types)
|
||||||
{
|
{
|
||||||
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
||||||
enum wined3d_sampler_texture_type *sampler_type = reg_maps->sampler_type;
|
enum wined3d_shader_resource_type *resource_type = reg_maps->resource_type;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (reg_maps->shader_version.major != 1) return;
|
if (reg_maps->shader_version.major != 1) return;
|
||||||
|
@ -2381,20 +2390,21 @@ void pixelshader_update_samplers(struct wined3d_shader *shader, WORD tex_types)
|
||||||
for (i = 0; i < shader->limits->sampler; ++i)
|
for (i = 0; i < shader->limits->sampler; ++i)
|
||||||
{
|
{
|
||||||
/* We don't sample from this sampler. */
|
/* We don't sample from this sampler. */
|
||||||
if (!sampler_type[i]) continue;
|
if (!resource_type[i])
|
||||||
|
continue;
|
||||||
|
|
||||||
switch ((tex_types >> i * WINED3D_PSARGS_TEXTYPE_SHIFT) & WINED3D_PSARGS_TEXTYPE_MASK)
|
switch ((tex_types >> i * WINED3D_PSARGS_TEXTYPE_SHIFT) & WINED3D_PSARGS_TEXTYPE_MASK)
|
||||||
{
|
{
|
||||||
case WINED3D_SHADER_TEX_2D:
|
case WINED3D_SHADER_TEX_2D:
|
||||||
sampler_type[i] = WINED3DSTT_2D;
|
resource_type[i] = WINED3D_SHADER_RESOURCE_TEXTURE_2D;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3D_SHADER_TEX_3D:
|
case WINED3D_SHADER_TEX_3D:
|
||||||
sampler_type[i] = WINED3DSTT_VOLUME;
|
resource_type[i] = WINED3D_SHADER_RESOURCE_TEXTURE_3D;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINED3D_SHADER_TEX_CUBE:
|
case WINED3D_SHADER_TEX_CUBE:
|
||||||
sampler_type[i] = WINED3DSTT_CUBE;
|
resource_type[i] = WINED3D_SHADER_RESOURCE_TEXTURE_CUBE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
|
||||||
#define WINED3DSP_DCL_USAGEINDEX_MASK (0xf << WINED3DSP_DCL_USAGEINDEX_SHIFT)
|
#define WINED3DSP_DCL_USAGEINDEX_MASK (0xf << WINED3DSP_DCL_USAGEINDEX_SHIFT)
|
||||||
|
|
||||||
/* DCL sampler type */
|
/* DCL sampler type */
|
||||||
#define WINED3DSP_TEXTURETYPE_SHIFT 27
|
#define WINED3D_SM1_RESOURCE_TYPE_SHIFT 27
|
||||||
#define WINED3DSP_TEXTURETYPE_MASK (0xf << WINED3DSP_TEXTURETYPE_SHIFT)
|
#define WINED3D_SM1_RESOURCE_TYPE_MASK (0xf << WINED3D_SM1_RESOURCE_TYPE_SHIFT)
|
||||||
|
|
||||||
/* Opcode-related masks */
|
/* Opcode-related masks */
|
||||||
#define WINED3DSI_OPCODE_MASK 0x0000ffff
|
#define WINED3DSI_OPCODE_MASK 0x0000ffff
|
||||||
|
@ -99,6 +99,15 @@ enum WINED3DSHADER_ADDRESSMODE_TYPE
|
||||||
WINED3DSHADER_ADDRMODE_RELATIVE = 1 << WINED3DSHADER_ADDRESSMODE_SHIFT,
|
WINED3DSHADER_ADDRMODE_RELATIVE = 1 << WINED3DSHADER_ADDRESSMODE_SHIFT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum wined3d_sm1_resource_type
|
||||||
|
{
|
||||||
|
WINED3D_SM1_RESOURCE_UNKNOWN = 0x0,
|
||||||
|
WINED3D_SM1_RESOURCE_TEXTURE_1D = 0x1,
|
||||||
|
WINED3D_SM1_RESOURCE_TEXTURE_2D = 0x2,
|
||||||
|
WINED3D_SM1_RESOURCE_TEXTURE_CUBE = 0x3,
|
||||||
|
WINED3D_SM1_RESOURCE_TEXTURE_3D = 0x4,
|
||||||
|
};
|
||||||
|
|
||||||
enum wined3d_sm1_opcode
|
enum wined3d_sm1_opcode
|
||||||
{
|
{
|
||||||
WINED3D_SM1_OP_NOP = 0x00,
|
WINED3D_SM1_OP_NOP = 0x00,
|
||||||
|
@ -377,6 +386,15 @@ static const struct wined3d_sm1_opcode_info ps_opcode_table[] =
|
||||||
{0, 0, 0, WINED3DSIH_TABLE_SIZE, 0, 0 },
|
{0, 0, 0, WINED3DSIH_TABLE_SIZE, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const enum wined3d_shader_resource_type resource_type_table[] =
|
||||||
|
{
|
||||||
|
/* WINED3D_SM1_RESOURCE_UNKNOWN */ WINED3D_SHADER_RESOURCE_NONE,
|
||||||
|
/* WINED3D_SM1_RESOURCE_TEXTURE_1D */ WINED3D_SHADER_RESOURCE_TEXTURE_1D,
|
||||||
|
/* WINED3D_SM1_RESOURCE_TEXTURE_2D */ WINED3D_SHADER_RESOURCE_TEXTURE_2D,
|
||||||
|
/* WINED3D_SM1_RESOURCE_TEXTURE_CUBE */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
|
||||||
|
/* WINED3D_SM1_RESOURCE_TEXTURE_3D */ WINED3D_SHADER_RESOURCE_TEXTURE_3D,
|
||||||
|
};
|
||||||
|
|
||||||
/* Read a parameter opcode from the input stream,
|
/* Read a parameter opcode from the input stream,
|
||||||
* and possibly a relative addressing token.
|
* and possibly a relative addressing token.
|
||||||
* Return the number of tokens read */
|
* Return the number of tokens read */
|
||||||
|
@ -612,12 +630,22 @@ static void shader_sm1_read_dst_param(struct wined3d_sm1_data *priv, const DWORD
|
||||||
|
|
||||||
static void shader_sm1_read_semantic(const DWORD **ptr, struct wined3d_shader_semantic *semantic)
|
static void shader_sm1_read_semantic(const DWORD **ptr, struct wined3d_shader_semantic *semantic)
|
||||||
{
|
{
|
||||||
|
enum wined3d_sm1_resource_type resource_type;
|
||||||
DWORD usage_token = *(*ptr)++;
|
DWORD usage_token = *(*ptr)++;
|
||||||
DWORD dst_token = *(*ptr)++;
|
DWORD dst_token = *(*ptr)++;
|
||||||
|
|
||||||
semantic->usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
|
semantic->usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
|
||||||
semantic->usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
|
semantic->usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
|
||||||
semantic->sampler_type = (usage_token & WINED3DSP_TEXTURETYPE_MASK) >> WINED3DSP_TEXTURETYPE_SHIFT;
|
resource_type = (usage_token & WINED3D_SM1_RESOURCE_TYPE_MASK) >> WINED3D_SM1_RESOURCE_TYPE_SHIFT;
|
||||||
|
if (resource_type >= ARRAY_SIZE(resource_type_table))
|
||||||
|
{
|
||||||
|
FIXME("Unhandled resource type %#x.\n", resource_type);
|
||||||
|
semantic->resource_type = WINED3D_SHADER_RESOURCE_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
semantic->resource_type = resource_type_table[resource_type];
|
||||||
|
}
|
||||||
shader_parse_dst_param(dst_token, NULL, &semantic->reg);
|
shader_parse_dst_param(dst_token, NULL, &semantic->reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,13 +283,13 @@ struct wined3d_settings
|
||||||
|
|
||||||
extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
|
extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
enum wined3d_sampler_texture_type
|
enum wined3d_shader_resource_type
|
||||||
{
|
{
|
||||||
WINED3DSTT_UNKNOWN = 0,
|
WINED3D_SHADER_RESOURCE_NONE,
|
||||||
WINED3DSTT_1D = 1,
|
WINED3D_SHADER_RESOURCE_TEXTURE_1D,
|
||||||
WINED3DSTT_2D = 2,
|
WINED3D_SHADER_RESOURCE_TEXTURE_2D,
|
||||||
WINED3DSTT_CUBE = 3,
|
WINED3D_SHADER_RESOURCE_TEXTURE_3D,
|
||||||
WINED3DSTT_VOLUME = 4,
|
WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WINED3D_SHADER_CONST_VS_F 0x00000001
|
#define WINED3D_SHADER_CONST_VS_F 0x00000001
|
||||||
|
@ -588,7 +588,7 @@ struct wined3d_shader_reg_maps
|
||||||
WORD local_bool_consts; /* MAX_CONST_B, 16 */
|
WORD local_bool_consts; /* MAX_CONST_B, 16 */
|
||||||
UINT cb_sizes[WINED3D_MAX_CBS];
|
UINT cb_sizes[WINED3D_MAX_CBS];
|
||||||
|
|
||||||
enum wined3d_sampler_texture_type sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
|
enum wined3d_shader_resource_type resource_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
|
||||||
BYTE bumpmat; /* MAX_TEXTURES, 8 */
|
BYTE bumpmat; /* MAX_TEXTURES, 8 */
|
||||||
BYTE luminanceparams; /* MAX_TEXTURES, 8 */
|
BYTE luminanceparams; /* MAX_TEXTURES, 8 */
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ struct wined3d_shader_semantic
|
||||||
{
|
{
|
||||||
enum wined3d_decl_usage usage;
|
enum wined3d_decl_usage usage;
|
||||||
UINT usage_idx;
|
UINT usage_idx;
|
||||||
enum wined3d_sampler_texture_type sampler_type;
|
enum wined3d_shader_resource_type resource_type;
|
||||||
struct wined3d_shader_dst_param reg;
|
struct wined3d_shader_dst_param reg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2910,7 +2910,7 @@ struct wined3d_shader
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
void pixelshader_update_samplers(struct wined3d_shader *shader, WORD tex_types) DECLSPEC_HIDDEN;
|
void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types) DECLSPEC_HIDDEN;
|
||||||
void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
|
void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
|
||||||
BOOL position_transformed, struct ps_compile_args *args,
|
BOOL position_transformed, struct ps_compile_args *args,
|
||||||
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
|
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue