Commit 4eaa424c authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

wined3d: Initial post pixelshader blending support. [attempt 2].

For each pixel format we store a flag in the table whether it supports post pixelshader blending. Before applying blending or during a context switch we verify that blending is turned off for the format. In case of R32F this gave a 5-6x performance boost (without filtering and software conversion).
parent 61f7dc00
......@@ -724,10 +724,12 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
* the alpha blend state changes with different render target formats
*/
if(oldFmt != newFmt) {
const GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL);
const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, NULL, NULL);
const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc);
if((old->alphaMask && !new->alphaMask) || (!old->alphaMask && new->alphaMask)) {
/* Disable blending when the alphaMask has changed and when a format doesn't support blending */
if((old->alphaMask && !new->alphaMask) || (!old->alphaMask && new->alphaMask) || !(glDesc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) {
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
}
}
......
......@@ -243,8 +243,18 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
glEnable(GL_BLEND);
checkGLcall("glEnable GL_BLEND");
const GlPixelFormatDesc *glDesc;
getFormatDescEntry(target->resource.format, &GLINFO_LOCATION, &glDesc);
/* When pixel shaders are used on a format that doesn't offer blending, disable blending else we could face a big performance penalty. */
if(!(glDesc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING) && use_ps(stateblock->wineD3DDevice)) {
glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
return;
} else {
glEnable(GL_BLEND);
checkGLcall("glEnable GL_BLEND");
}
} else {
glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
......
......@@ -30,6 +30,9 @@ typedef enum {
WINED3D_DCS_NO_COPY = 2
} WINED3D_DEPTHCOPYSTATE;
/* WineD3D pixel format flags */
#define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x1
/** DCL usage masks **/
#define WINED3DSP_DCL_USAGE_SHIFT 0
#define WINED3DSP_DCL_USAGE_MASK 0x0000000f
......
......@@ -3784,6 +3784,7 @@ typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer,
typedef struct {
GLint glInternal, glGammaInternal, rtInternal, glFormat, glType;
WINED3DFORMAT conversion_group;
unsigned int Flags;
} GlPixelFormatDesc;
typedef struct _WINED3DGLTYPE {
......
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