Commit 0680b175 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Store ps 1.4 texture types in ps_compile_args.

parent 547be26d
......@@ -4354,7 +4354,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;
pixelshader_update_samplers(&shader->reg_maps, device->stateBlock->state.textures);
pixelshader_update_samplers(shader, args->super.tex_types);
if (!shader_buffer_init(&buffer))
{
......
......@@ -4627,7 +4627,6 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
const struct ps_compile_args *args, const struct ps_np2fixup_info **np2fixup_info)
{
struct wined3d_state *state = &shader->device->stateBlock->state;
struct glsl_ps_compiled_shader *gl_shaders, *new_array;
struct glsl_shader_private *shader_data;
struct ps_np2fixup_info *np2fixup;
......@@ -4690,7 +4689,7 @@ static GLhandleARB find_glsl_pshader(const struct wined3d_context *context,
memset(np2fixup, 0, sizeof(*np2fixup));
*np2fixup_info = args->np2_fixup ? np2fixup : NULL;
pixelshader_update_samplers(&shader->reg_maps, state->textures);
pixelshader_update_samplers(shader, args->tex_types);
shader_buffer_clear(buffer);
ret = shader_glsl_generate_pshader(context, buffer, shader, args, np2fixup);
......
......@@ -2062,6 +2062,39 @@ void find_ps_compile_args(const struct wined3d_state *state,
}
}
}
if (shader->reg_maps.shader_version.major == 1
&& shader->reg_maps.shader_version.minor <= 4)
{
for (i = 0; i < shader->limits.sampler; ++i)
{
const struct wined3d_texture *texture = state->textures[i];
if (!shader->reg_maps.sampler_type[i])
continue;
/* Treat unbound textures as 2D. The dummy texture will provide
* the proper sample value. The tex_types bitmap defaults to
* 2D because of the memset. */
if (!texture)
continue;
switch (texture->target)
{
/* RECT textures are distinguished from 2D textures via np2_fixup */
case GL_TEXTURE_RECTANGLE_ARB:
case GL_TEXTURE_2D:
break;
case GL_TEXTURE_3D:
args->tex_types |= WINED3D_SHADER_TEX_3D << i * WINED3D_PSARGS_TEXTYPE_SHIFT;
break;
case GL_TEXTURE_CUBE_MAP_ARB:
args->tex_types |= WINED3D_SHADER_TEX_CUBE << i * WINED3D_PSARGS_TEXTYPE_SHIFT;
break;
}
}
}
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
{
......@@ -2274,46 +2307,32 @@ static HRESULT pixelshader_init(struct wined3d_shader *shader, struct wined3d_de
return WINED3D_OK;
}
void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps, struct wined3d_texture * const *textures)
void pixelshader_update_samplers(struct wined3d_shader *shader, WORD tex_types)
{
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
enum wined3d_sampler_texture_type *sampler_type = reg_maps->sampler_type;
unsigned int i;
if (reg_maps->shader_version.major != 1) return;
for (i = 0; i < max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS); ++i)
for (i = 0; i < shader->limits.sampler; ++i)
{
/* We don't sample from this sampler. */
if (!sampler_type[i]) continue;
if (!textures[i])
switch ((tex_types >> i * WINED3D_PSARGS_TEXTYPE_SHIFT) & WINED3D_PSARGS_TEXTYPE_MASK)
{
WARN("No texture bound to sampler %u, using 2D.\n", i);
sampler_type[i] = WINED3DSTT_2D;
continue;
}
switch (textures[i]->target)
{
case GL_TEXTURE_RECTANGLE_ARB:
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. */
case WINED3D_SHADER_TEX_2D:
sampler_type[i] = WINED3DSTT_2D;
break;
case GL_TEXTURE_3D:
case WINED3D_SHADER_TEX_3D:
sampler_type[i] = WINED3DSTT_VOLUME;
break;
case GL_TEXTURE_CUBE_MAP_ARB:
case WINED3D_SHADER_TEX_CUBE:
sampler_type[i] = WINED3DSTT_CUBE;
break;
default:
FIXME("Unrecognized texture type %#x, using 2D.\n", textures[i]->target);
sampler_type[i] = WINED3DSTT_2D;
}
}
}
......
......@@ -746,13 +746,25 @@ enum fogmode {
#define WINED3D_PSARGS_PROJECTED (1 << 3)
#define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
#define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xf
#define WINED3D_PSARGS_TEXTYPE_SHIFT 2
#define WINED3D_PSARGS_TEXTYPE_MASK 0x3
/* Similar to tex_types, except that it doesn't have 1d textures
* (can't be bound), rect textures (handled via np2_fixup) and
* none / unknown (treated as 2d and handled via dummy textures). */
enum wined3d_shader_tex_types
{
WINED3D_SHADER_TEX_2D = 0,
WINED3D_SHADER_TEX_3D = 1,
WINED3D_SHADER_TEX_CUBE = 2,
};
struct ps_compile_args {
struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
enum vertexprocessing_mode vp_mode;
enum fogmode fog;
WORD tex_transform; /* ps 1.0-1.3, 4 textures */
/* Texture types(2D, Cube, 3D) in ps 1.x */
WORD tex_types; /* ps 1.0 - 1.4, 6 textures */
WORD srgb_correction;
WORD np2_fixup;
/* Bitmap for NP2 texcoord fixups (16 samplers max currently).
......@@ -2635,8 +2647,7 @@ struct wined3d_shader
} u;
};
void pixelshader_update_samplers(struct wined3d_shader_reg_maps *reg_maps,
struct wined3d_texture * const *textures) DECLSPEC_HIDDEN;
void pixelshader_update_samplers(struct wined3d_shader *shader, WORD tex_types) DECLSPEC_HIDDEN;
void find_ps_compile_args(const struct wined3d_state *state,
const struct wined3d_shader *shader, struct ps_compile_args *args) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment