wined3d: glsl: Enable load_np2fixup_constants.

This commit is contained in:
Tobias Jakobi 2009-04-09 01:43:02 +02:00 committed by Alexandre Julliard
parent 9b067a6ca5
commit 6e970c5d95
3 changed files with 42 additions and 23 deletions

View File

@ -670,6 +670,12 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
} else {
tex_type = "2D";
}
if(shader_is_pshader_version(ins->reg_maps->shader_version)) {
const IWineD3DPixelShaderImpl* const ps = (const IWineD3DPixelShaderImpl*)This;
if(ps->cur_args->texrect_fixup & (1 << sampler_idx)) {
FIXME("NP2 texcoord fixup is currently not implemented in ARB mode (use GLSL instead).");
}
}
break;
case WINED3DSTT_VOLUME:

View File

@ -489,7 +489,39 @@ static void shader_glsl_load_np2fixup_constants(
IWineD3DDevice* device,
char usePixelShader,
char useVertexShader) {
/* not implemented */
const IWineD3DDeviceImpl* deviceImpl = (const IWineD3DDeviceImpl*) device;
const struct glsl_shader_prog_link* prog = ((struct shader_glsl_priv *)(deviceImpl->shader_priv))->glsl_program;
if (!prog) {
/* No GLSL program set - nothing to do. */
return;
}
if (!usePixelShader) {
/* NP2 texcoord fixup is (currently) only done for pixelshaders. */
return;
}
if (prog->ps_args.texrect_fixup) {
UINT i;
UINT fixup = prog->ps_args.texrect_fixup;
const WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
const IWineD3DStateBlockImpl* stateBlock = (const IWineD3DStateBlockImpl*) deviceImpl->stateBlock;
for (i = 0; fixup; fixup >>= 1, ++i) {
if (-1 != prog->rectFixup_location[i]) {
const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
if (!tex) {
FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n");
continue;
} else {
const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]};
GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim));
}
}
}
}
}
/**
@ -598,24 +630,6 @@ static void shader_glsl_load_constants(
}
GL_EXTCALL(glUniform4fvARB(prog->ycorrection_location, 1, correction_params));
}
/* Constant loading for texture rect coord fixup. */
if (prog->ps_args.texrect_fixup) {
UINT fixup = prog->ps_args.texrect_fixup;
for (i = 0; fixup; fixup >>= 1, ++i) {
if (-1 != prog->rectFixup_location[i]) {
const IWineD3DBaseTextureImpl* const tex = (const IWineD3DBaseTextureImpl*) stateBlock->textures[i];
if (!tex) {
FIXME("Non-existant texture is flagged for NP2 texcoord fixup\n");
continue;
} else {
const float tex_dim[2] = {tex->baseTexture.pow2Matrix[0], tex->baseTexture.pow2Matrix[5]};
GL_EXTCALL(glUniform2fvARB(prog->rectFixup_location[i], 1, tex_dim));
}
}
}
}
}
if (priv->next_constant_version == UINT_MAX)

View File

@ -3367,11 +3367,10 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
/* Trigger shader constant reloading (for NP2 texcoord fixup)
* Only do this if pshaders are used (note: fixup is currently only implemented in GLSL). */
if (!tex_impl->baseTexture.pow2Matrix_identity && use_ps(stateblock)) {
if (!tex_impl->baseTexture.pow2Matrix_identity) {
IWineD3DDeviceImpl* d3ddevice = stateblock->wineD3DDevice;
/* FIXME: add something like shader_load_rectfixup_consts to the backend to only reload the
* constants that are used for the fixup (and not the other ones too) */
d3ddevice->shader_backend->shader_load_constants((IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock));
d3ddevice->shader_backend->shader_load_np2fixup_constants(
(IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock));
}
} else if(mapped_stage < GL_LIMITS(textures)) {
if(sampler < stateblock->lowest_disabled_stage) {