mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 10:13:56 +00:00
wined3d: Store currently active texture in the wined3d context.
This commit is contained in:
parent
e53ae83d74
commit
f47f9f7c74
8 changed files with 36 additions and 41 deletions
|
@ -6875,7 +6875,7 @@ static GLuint gen_p8_shader(struct arbfp_blit_priv *priv,
|
|||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
static void upload_palette(struct wined3d_surface *surface)
|
||||
static void upload_palette(struct wined3d_surface *surface, struct wined3d_context *context)
|
||||
{
|
||||
BYTE table[256][4];
|
||||
struct wined3d_device *device = surface->resource.device;
|
||||
|
@ -6903,7 +6903,7 @@ static void upload_palette(struct wined3d_surface *surface)
|
|||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, table);
|
||||
|
||||
/* Switch back to unit 0 in which the 2D texture will be stored. */
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0));
|
||||
context_active_texture(context, gl_info, 0);
|
||||
LEAVE_GL();
|
||||
}
|
||||
|
||||
|
@ -7105,7 +7105,7 @@ static HRESULT arbfp_blit_set(void *blit_priv, struct wined3d_context *context,
|
|||
shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->p8_rect_shader : priv->p8_2d_shader;
|
||||
if (!shader) shader = gen_p8_shader(priv, gl_info, textype);
|
||||
|
||||
upload_palette(surface);
|
||||
upload_palette(surface, context);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -837,8 +837,7 @@ static void set_tex_op_atifs(struct wined3d_context *context, const struct wined
|
|||
mapped_stage = device->texUnitMap[i];
|
||||
if (mapped_stage != WINED3D_UNMAPPED_STAGE)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
texture_activate_dimensions(state->textures[i], gl_info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1498,7 +1498,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
|
|||
*/
|
||||
for (s = 1; s < gl_info->limits.textures; ++s)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s));
|
||||
context_active_texture(ret, gl_info, s);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + s - 1);
|
||||
checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ...");
|
||||
}
|
||||
|
@ -1527,7 +1527,7 @@ struct wined3d_context *context_create(struct wined3d_swapchain *swapchain,
|
|||
{
|
||||
for (s = 0; s < gl_info->limits.textures; ++s)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s));
|
||||
context_active_texture(ret, gl_info, s);
|
||||
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
|
||||
checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
|
||||
}
|
||||
|
@ -1667,8 +1667,7 @@ static void SetupForBlit(struct wined3d_device *device, struct wined3d_context *
|
|||
for (i = gl_info->limits.textures - 1; i > 0 ; --i)
|
||||
{
|
||||
sampler = device->rev_tex_unit_map[i];
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, i);
|
||||
|
||||
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
|
||||
{
|
||||
|
@ -1695,8 +1694,7 @@ static void SetupForBlit(struct wined3d_device *device, struct wined3d_context *
|
|||
context_invalidate_state(context, STATE_SAMPLER(sampler));
|
||||
}
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, 0);
|
||||
|
||||
sampler = device->rev_tex_unit_map[0];
|
||||
|
||||
|
@ -1882,6 +1880,14 @@ void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
|
|||
context->draw_buffers_mask = context_generate_rt_mask(buffer);
|
||||
}
|
||||
|
||||
/* GL locking is done by the caller. */
|
||||
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0 + unit));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context->active_texture = unit;
|
||||
}
|
||||
|
||||
static void context_set_render_offscreen(struct wined3d_context *context, BOOL offscreen)
|
||||
{
|
||||
if (context->render_offscreen == offscreen) return;
|
||||
|
|
|
@ -967,7 +967,7 @@ out:
|
|||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
static void create_dummy_textures(struct wined3d_device *device)
|
||||
static void create_dummy_textures(struct wined3d_device *device, struct wined3d_context *context)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
unsigned int i;
|
||||
|
@ -989,8 +989,7 @@ static void create_dummy_textures(struct wined3d_device *device)
|
|||
DWORD color = 0x000000ff;
|
||||
|
||||
/* Make appropriate texture active */
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, i);
|
||||
|
||||
/* Generate an opengl texture name */
|
||||
glGenTextures(1, &device->dummyTextureName[i]);
|
||||
|
@ -1272,7 +1271,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
|
|||
|
||||
context = context_acquire(device, swapchain->front_buffer);
|
||||
|
||||
create_dummy_textures(device);
|
||||
create_dummy_textures(device, context);
|
||||
|
||||
ENTER_GL();
|
||||
|
||||
|
@ -4833,8 +4832,7 @@ HRESULT CDECL wined3d_device_update_surface(struct wined3d_device *device,
|
|||
gl_info = context->gl_info;
|
||||
|
||||
ENTER_GL();
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, 0);
|
||||
LEAVE_GL();
|
||||
|
||||
/* Only load the surface for partial updates. For newly allocated texture
|
||||
|
@ -5281,8 +5279,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
|
|||
}
|
||||
|
||||
/* Make sure that a proper texture unit is selected */
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, 0);
|
||||
sampler = device->rev_tex_unit_map[0];
|
||||
if (sampler != WINED3D_UNMAPPED_STAGE)
|
||||
context_invalidate_state(context, STATE_SAMPLER(sampler));
|
||||
|
@ -5588,7 +5585,7 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru
|
|||
|
||||
swapchain->context[0] = context;
|
||||
swapchain->num_contexts = 1;
|
||||
create_dummy_textures(device);
|
||||
create_dummy_textures(device, context);
|
||||
context_release(context);
|
||||
|
||||
hr = device->shader_backend->shader_alloc_private(device);
|
||||
|
|
|
@ -479,8 +479,7 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
|
|||
FIXME("Attempt to enable unsupported stage!\n");
|
||||
return;
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
}
|
||||
|
||||
if (state->lowest_disabled_stage > 0)
|
||||
|
@ -558,11 +557,9 @@ static void nvrc_colorop(struct wined3d_context *context, const struct wined3d_s
|
|||
BOOL usedBump = !!(context->texShaderBumpMap & 1 << (stage + 1));
|
||||
if (usesBump != usedBump)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage + 1));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage + 1);
|
||||
nvts_activate_dimensions(state, stage + 1, context);
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -598,8 +595,7 @@ static void nvts_bumpenvmat(struct wined3d_context *context, const struct wined3
|
|||
*/
|
||||
if (mapped_stage < gl_info->limits.textures)
|
||||
{
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage))");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
|
||||
/* We can't just pass a pointer to the state to GL due to the
|
||||
* different matrix format (column major vs row major). */
|
||||
|
|
|
@ -753,8 +753,7 @@ static void state_texfactor(struct wined3d_context *context, const struct wined3
|
|||
/* Note the WINED3DRS value applies to all textures, but GL has one
|
||||
* per texture, so apply it now ready to be used!
|
||||
*/
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, i);
|
||||
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
|
||||
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
|
||||
|
@ -3031,8 +3030,7 @@ static void tex_colorop(struct wined3d_context *context, const struct wined3d_st
|
|||
FIXME("Attempt to enable unsupported stage!\n");
|
||||
return;
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
}
|
||||
|
||||
if (stage >= state->lowest_disabled_stage)
|
||||
|
@ -3090,8 +3088,7 @@ void tex_alphaop(struct wined3d_context *context, const struct wined3d_state *st
|
|||
FIXME("Attempt to enable unsupported stage!\n");
|
||||
return;
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
}
|
||||
|
||||
op = state->texture_states[stage][WINED3DTSS_ALPHAOP];
|
||||
|
@ -3193,8 +3190,7 @@ static void transform_texture(struct wined3d_context *context, const struct wine
|
|||
if (mapped_stage == WINED3D_UNMAPPED_STAGE) return;
|
||||
if (mapped_stage >= gl_info->limits.textures) return;
|
||||
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
generated = (state->texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU;
|
||||
coordIdx = min(state->texture_states[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000ffff], MAX_TEXTURES - 1);
|
||||
|
||||
|
@ -3309,8 +3305,7 @@ static void tex_coordindex(struct wined3d_context *context, const struct wined3d
|
|||
WARN("stage %u not mapped to a valid texture unit (%u)\n", stage, mapped_stage);
|
||||
return;
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
|
||||
/* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
|
||||
*
|
||||
|
@ -3538,8 +3533,7 @@ static void sampler(struct wined3d_context *context, const struct wined3d_state
|
|||
{
|
||||
return;
|
||||
}
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
|
||||
checkGLcall("glActiveTextureARB");
|
||||
context_active_texture(context, gl_info, mapped_stage);
|
||||
|
||||
if (state->textures[sampler])
|
||||
{
|
||||
|
|
|
@ -5602,7 +5602,7 @@ static void surface_depth_blt(const struct wined3d_surface *surface, struct wine
|
|||
|
||||
SetRect(&rect, 0, h, w, 0);
|
||||
surface_get_blt_info(target, &rect, surface->pow2Width, surface->pow2Height, &info);
|
||||
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
|
||||
context_active_texture(context, context->gl_info, 0);
|
||||
glGetIntegerv(info.binding, &old_binding);
|
||||
glBindTexture(info.bind_target, texture);
|
||||
if (gl_info->supported[ARB_SHADOW])
|
||||
|
|
|
@ -1088,6 +1088,7 @@ struct wined3d_context
|
|||
GLenum untracked_materials[2];
|
||||
UINT blit_w, blit_h;
|
||||
enum fogsource fog_source;
|
||||
DWORD active_texture;
|
||||
|
||||
char *vshader_const_dirty, *pshader_const_dirty;
|
||||
|
||||
|
@ -1234,6 +1235,8 @@ BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_d
|
|||
BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device) DECLSPEC_HIDDEN;
|
||||
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
|
||||
struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location) DECLSPEC_HIDDEN;
|
||||
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info,
|
||||
unsigned int unit) DECLSPEC_HIDDEN;
|
||||
void context_check_fbo_status(const struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN;
|
||||
struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_surface *target,
|
||||
const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in a new issue