wined3d: Avoid hardcoding GL_TEXTURE_2D.
This commit is contained in:
parent
4dbee07ff5
commit
7925ef35cd
|
@ -1229,8 +1229,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
|
||||||
glGenTextures(1, &This->glDescription.textureName);
|
glGenTextures(1, &This->glDescription.textureName);
|
||||||
checkGLcall("glGenTextures");
|
checkGLcall("glGenTextures");
|
||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);
|
glBindTexture(This->glDescription.target, This->glDescription.textureName);
|
||||||
checkGLcall("glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);");
|
checkGLcall("glBindTexture(This->glDescription.target, This->glDescription.textureName)");
|
||||||
LEAVE_GL();
|
LEAVE_GL();
|
||||||
IWineD3DSurface_LoadLocation(iface, SFLAG_INTEXTURE, NULL /* partial texture loading not supported yet */);
|
IWineD3DSurface_LoadLocation(iface, SFLAG_INTEXTURE, NULL /* partial texture loading not supported yet */);
|
||||||
/* drop through */
|
/* drop through */
|
||||||
|
@ -2020,7 +2020,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
|
||||||
if(GL_SUPPORT(EXT_PALETTED_TEXTURE))
|
if(GL_SUPPORT(EXT_PALETTED_TEXTURE))
|
||||||
{
|
{
|
||||||
TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n");
|
TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n");
|
||||||
GL_EXTCALL(glColorTableEXT(GL_TEXTURE_2D,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE, table));
|
GL_EXTCALL(glColorTableEXT(This->glDescription.target,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE, table));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2527,11 +2527,11 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
|
||||||
IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
|
IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
|
||||||
|
|
||||||
/* TODO: Do we need GL_TEXTURE_2D enabled fpr copyteximage? */
|
/* TODO: Do we need GL_TEXTURE_2D enabled fpr copyteximage? */
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(This->glDescription.target);
|
||||||
checkGLcall("glEnable(GL_TEXTURE_2D)");
|
checkGLcall("glEnable(This->glDescription.target)");
|
||||||
|
|
||||||
/* Bind the target texture */
|
/* Bind the target texture */
|
||||||
glBindTexture(GL_TEXTURE_2D, This->glDescription.textureName);
|
glBindTexture(This->glDescription.target, This->glDescription.textureName);
|
||||||
checkGLcall("glBindTexture");
|
checkGLcall("glBindTexture");
|
||||||
if(!swapchain) {
|
if(!swapchain) {
|
||||||
glReadBuffer(myDevice->offscreenBuffer);
|
glReadBuffer(myDevice->offscreenBuffer);
|
||||||
|
@ -2598,8 +2598,8 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
|
||||||
vcheckGLcall("glCopyTexSubImage2D");
|
vcheckGLcall("glCopyTexSubImage2D");
|
||||||
|
|
||||||
/* Leave the opengl state valid for blitting */
|
/* Leave the opengl state valid for blitting */
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(This->glDescription.target);
|
||||||
checkGLcall("glDisable(GL_TEXTURE_2D)");
|
checkGLcall("glDisable(This->glDescription.target)");
|
||||||
|
|
||||||
LEAVE_GL();
|
LEAVE_GL();
|
||||||
}
|
}
|
||||||
|
@ -2613,13 +2613,12 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
UINT fbwidth = Src->currentDesc.Width;
|
UINT fbwidth = Src->currentDesc.Width;
|
||||||
UINT fbheight = Src->currentDesc.Height;
|
UINT fbheight = Src->currentDesc.Height;
|
||||||
GLenum drawBuffer = GL_BACK;
|
GLenum drawBuffer = GL_BACK;
|
||||||
|
GLenum texture_target;
|
||||||
|
|
||||||
TRACE("Using hwstretch blit\n");
|
TRACE("Using hwstretch blit\n");
|
||||||
/* Activate the Proper context for reading from the source surface, set it up for blitting */
|
/* Activate the Proper context for reading from the source surface, set it up for blitting */
|
||||||
ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
|
ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
checkGLcall("glEnable(GL_TEXTURE_2D)");
|
|
||||||
|
|
||||||
IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
|
IWineD3DSurface_PreLoad((IWineD3DSurface *) This);
|
||||||
|
|
||||||
|
@ -2639,6 +2638,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
checkGLcall("glGenTextures\n");
|
checkGLcall("glGenTextures\n");
|
||||||
glBindTexture(GL_TEXTURE_2D, backup);
|
glBindTexture(GL_TEXTURE_2D, backup);
|
||||||
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
|
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
|
||||||
|
texture_target = GL_TEXTURE_2D;
|
||||||
} else {
|
} else {
|
||||||
/* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If
|
/* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If
|
||||||
* we are reading from the back buffer, the backup can be used as source texture
|
* we are reading from the back buffer, the backup can be used as source texture
|
||||||
|
@ -2647,8 +2647,11 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
/* Get it a description */
|
/* Get it a description */
|
||||||
IWineD3DSurface_PreLoad(SrcSurface);
|
IWineD3DSurface_PreLoad(SrcSurface);
|
||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName);
|
texture_target = Src->glDescription.target;
|
||||||
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
|
glBindTexture(texture_target, Src->glDescription.textureName);
|
||||||
|
checkGLcall("glBindTexture(texture_target, Src->glDescription.textureName)");
|
||||||
|
glEnable(texture_target);
|
||||||
|
checkGLcall("glEnable(texture_target)");
|
||||||
|
|
||||||
/* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */
|
/* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */
|
||||||
Src->Flags &= ~SFLAG_INTEXTURE;
|
Src->Flags &= ~SFLAG_INTEXTURE;
|
||||||
|
@ -2658,7 +2661,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
checkGLcall("glReadBuffer(GL_BACK)");
|
checkGLcall("glReadBuffer(GL_BACK)");
|
||||||
|
|
||||||
/* TODO: Only back up the part that will be overwritten */
|
/* TODO: Only back up the part that will be overwritten */
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
|
glCopyTexSubImage2D(texture_target, 0,
|
||||||
0, 0 /* read offsets */,
|
0, 0 /* read offsets */,
|
||||||
0, 0,
|
0, 0,
|
||||||
fbwidth,
|
fbwidth,
|
||||||
|
@ -2667,10 +2670,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
checkGLcall("glCopyTexSubImage2D");
|
checkGLcall("glCopyTexSubImage2D");
|
||||||
|
|
||||||
/* No issue with overriding these - the sampler is dirty due to blit usage */
|
/* No issue with overriding these - the sampler is dirty due to blit usage */
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER,
|
||||||
stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]);
|
stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]);
|
||||||
checkGLcall("glTexParameteri");
|
checkGLcall("glTexParameteri");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
|
||||||
minMipLookup[Filter][WINED3DTEXF_NONE]);
|
minMipLookup[Filter][WINED3DTEXF_NONE]);
|
||||||
checkGLcall("glTexParameteri");
|
checkGLcall("glTexParameteri");
|
||||||
|
|
||||||
|
@ -2704,6 +2707,12 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
|
|
||||||
glReadBuffer(GL_BACK);
|
glReadBuffer(GL_BACK);
|
||||||
checkGLcall("glReadBuffer(GL_BACK)");
|
checkGLcall("glReadBuffer(GL_BACK)");
|
||||||
|
|
||||||
|
if(texture_target != GL_TEXTURE_2D) {
|
||||||
|
glDisable(texture_target);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
texture_target = GL_TEXTURE_2D;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
checkGLcall("glEnd and previous");
|
checkGLcall("glEnd and previous");
|
||||||
|
|
||||||
|
@ -2719,8 +2728,8 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw the source texture stretched and upside down. The correct surface is bound already */
|
/* draw the source texture stretched and upside down. The correct surface is bound already */
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
|
|
||||||
glDrawBuffer(drawBuffer);
|
glDrawBuffer(drawBuffer);
|
||||||
glReadBuffer(drawBuffer);
|
glReadBuffer(drawBuffer);
|
||||||
|
@ -2744,21 +2753,42 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
glEnd();
|
glEnd();
|
||||||
checkGLcall("glEnd and previous");
|
checkGLcall("glEnd and previous");
|
||||||
|
|
||||||
|
if(texture_target != This->glDescription.target) {
|
||||||
|
glDisable(texture_target);
|
||||||
|
glEnable(This->glDescription.target);
|
||||||
|
texture_target = This->glDescription.target;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now read the stretched and upside down image into the destination texture */
|
/* Now read the stretched and upside down image into the destination texture */
|
||||||
glBindTexture(This->glDescription.target, This->glDescription.textureName);
|
glBindTexture(texture_target, This->glDescription.textureName);
|
||||||
checkGLcall("glBindTexture");
|
checkGLcall("glBindTexture");
|
||||||
glCopyTexSubImage2D(This->glDescription.target,
|
glCopyTexSubImage2D(texture_target,
|
||||||
0,
|
0,
|
||||||
drect->x1, drect->y1, /* xoffset, yoffset */
|
drect->x1, drect->y1, /* xoffset, yoffset */
|
||||||
0, 0, /* We blitted the image to the origin */
|
0, 0, /* We blitted the image to the origin */
|
||||||
drect->x2 - drect->x1, drect->y2 - drect->y1);
|
drect->x2 - drect->x1, drect->y2 - drect->y1);
|
||||||
checkGLcall("glCopyTexSubImage2D");
|
checkGLcall("glCopyTexSubImage2D");
|
||||||
|
|
||||||
/* Write the back buffer backup back */
|
|
||||||
glBindTexture(GL_TEXTURE_2D, backup ? backup : Src->glDescription.textureName);
|
|
||||||
checkGLcall("glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName)");
|
|
||||||
|
|
||||||
if(drawBuffer == GL_BACK) {
|
if(drawBuffer == GL_BACK) {
|
||||||
|
/* Write the back buffer backup back */
|
||||||
|
if(backup) {
|
||||||
|
if(texture_target != GL_TEXTURE_2D) {
|
||||||
|
glDisable(texture_target);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
texture_target = GL_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
glBindTexture(GL_TEXTURE_2D, backup);
|
||||||
|
checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)");
|
||||||
|
} else {
|
||||||
|
if(texture_target != Src->glDescription.target) {
|
||||||
|
glDisable(texture_target);
|
||||||
|
glEnable(Src->glDescription.target);
|
||||||
|
texture_target = Src->glDescription.target;
|
||||||
|
}
|
||||||
|
glBindTexture(Src->glDescription.target, Src->glDescription.textureName);
|
||||||
|
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
|
||||||
|
}
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
/* top left */
|
/* top left */
|
||||||
glTexCoord2f(0.0, (float) fbheight / (float) Src->pow2Height);
|
glTexCoord2f(0.0, (float) fbheight / (float) Src->pow2Height);
|
||||||
|
@ -2780,10 +2810,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
|
||||||
/* Restore the old draw buffer */
|
/* Restore the old draw buffer */
|
||||||
glDrawBuffer(GL_BACK);
|
glDrawBuffer(GL_BACK);
|
||||||
}
|
}
|
||||||
|
glDisable(texture_target);
|
||||||
|
checkGLcall("glDisable(texture_target)");
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
checkGLcall("glDisable(GL_TEXTURE_2D)");
|
|
||||||
if(src != Src->glDescription.textureName && src != backup) {
|
if(src != Src->glDescription.textureName && src != backup) {
|
||||||
glDeleteTextures(1, &src);
|
glDeleteTextures(1, &src);
|
||||||
checkGLcall("glDeleteTextures(1, &src)");
|
checkGLcall("glDeleteTextures(1, &src)");
|
||||||
|
@ -3099,8 +3129,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
ActivateContext(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
|
ActivateContext(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
|
||||||
ENTER_GL();
|
ENTER_GL();
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(Src->glDescription.target);
|
||||||
checkGLcall("glEnable(GL_TEXTURE_2D)");
|
checkGLcall("glEnable(Src->glDescription.target)");
|
||||||
|
|
||||||
if(!dstSwapchain) {
|
if(!dstSwapchain) {
|
||||||
TRACE("Drawing to offscreen buffer\n");
|
TRACE("Drawing to offscreen buffer\n");
|
||||||
|
@ -3114,18 +3144,18 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind the texture */
|
/* Bind the texture */
|
||||||
glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName);
|
glBindTexture(Src->glDescription.target, Src->glDescription.textureName);
|
||||||
checkGLcall("glBindTexture");
|
checkGLcall("glBindTexture");
|
||||||
|
|
||||||
/* Filtering for StretchRect */
|
/* Filtering for StretchRect */
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MAG_FILTER,
|
||||||
stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]);
|
stateLookup[WINELOOKUP_MAGFILTER][Filter - minLookup[WINELOOKUP_MAGFILTER]]);
|
||||||
checkGLcall("glTexParameteri");
|
checkGLcall("glTexParameteri");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
|
||||||
minMipLookup[Filter][WINED3DTEXF_NONE]);
|
minMipLookup[Filter][WINED3DTEXF_NONE]);
|
||||||
checkGLcall("glTexParameteri");
|
checkGLcall("glTexParameteri");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
checkGLcall("glTexEnvi");
|
checkGLcall("glTexEnvi");
|
||||||
|
|
||||||
|
@ -3174,11 +3204,11 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
|
||||||
if(dstSwapchain && (dstSwapchain->num_contexts >= 2))
|
if(dstSwapchain && (dstSwapchain->num_contexts >= 2))
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(Src->glDescription.target, 0);
|
||||||
checkGLcall("glEnable glBindTexture");
|
checkGLcall("glBindTexture(Src->glDescription.target, 0)");
|
||||||
/* Leave the opengl state valid for blitting */
|
/* Leave the opengl state valid for blitting */
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(Src->glDescription.target);
|
||||||
checkGLcall("glDisable(GL_TEXTURE_2D)");
|
checkGLcall("glDisable(Src->glDescription.target)");
|
||||||
|
|
||||||
/* The draw buffer should only need to be restored if we were drawing to the front buffer, and there is a back buffer.
|
/* The draw buffer should only need to be restored if we were drawing to the front buffer, and there is a back buffer.
|
||||||
* otherwise the context manager should choose between GL_BACK / offscreenDrawBuffer
|
* otherwise the context manager should choose between GL_BACK / offscreenDrawBuffer
|
||||||
|
|
Loading…
Reference in New Issue