Commit 69b76122 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of struct glDescriptor.

In general it might not be a bad idea to group GL specific data into a separate struct, but IWineD3DSurfaceImpl is currently the only thing that bothers. It doesn't get it quite right either, since e.g. the PBO isn't in glDescriptor either.
parent 038d9399
......@@ -130,7 +130,7 @@ static void context_apply_attachment_filter_states(IWineD3DDevice *iface, IWineD
GLenum target, bind_target;
GLint old_binding;
target = surface_impl->glDescription.target;
target = surface_impl->texture_target;
if (target == GL_TEXTURE_2D)
{
bind_target = GL_TEXTURE_2D;
......@@ -145,7 +145,7 @@ static void context_apply_attachment_filter_states(IWineD3DDevice *iface, IWineD
surface_internal_preload(surface, SRGB_RGB);
glBindTexture(bind_target, surface_impl->glDescription.textureName);
glBindTexture(bind_target, surface_impl->texture_name);
if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(bind_target, old_binding);
......@@ -188,16 +188,16 @@ void context_attach_depth_stencil_fbo(IWineD3DDeviceImpl *This, GLenum fbo_targe
if (format_flags & WINED3DFMT_FLAG_DEPTH)
{
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT,
depth_stencil_impl->glDescription.target, depth_stencil_impl->glDescription.textureName,
depth_stencil_impl->glDescription.level));
depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
depth_stencil_impl->texture_level));
checkGLcall("glFramebufferTexture2DEXT()");
}
if (format_flags & WINED3DFMT_FLAG_STENCIL)
{
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_STENCIL_ATTACHMENT_EXT,
depth_stencil_impl->glDescription.target, depth_stencil_impl->glDescription.textureName,
depth_stencil_impl->glDescription.level));
depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
depth_stencil_impl->texture_level));
checkGLcall("glFramebufferTexture2DEXT()");
}
}
......@@ -235,8 +235,8 @@ void context_attach_surface_fbo(IWineD3DDeviceImpl *This, GLenum fbo_target, DWO
{
context_apply_attachment_filter_states((IWineD3DDevice *)This, surface, TRUE);
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, surface_impl->glDescription.target,
surface_impl->glDescription.textureName, surface_impl->glDescription.level));
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, surface_impl->texture_target,
surface_impl->texture_name, surface_impl->texture_level));
checkGLcall("glFramebufferTexture2DEXT()");
} else {
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, GL_TEXTURE_2D, 0, 0));
......@@ -1636,7 +1636,8 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
/* Do that before switching the context:
* Read the back buffer of the old drawable into the destination texture
*/
if(((IWineD3DSurfaceImpl *)This->lastActiveRenderTarget)->glDescription.srgbTextureName) {
if (((IWineD3DSurfaceImpl *)This->lastActiveRenderTarget)->texture_name_srgb)
{
surface_internal_preload(This->lastActiveRenderTarget, SRGB_BOTH);
} else {
surface_internal_preload(This->lastActiveRenderTarget, SRGB_RGB);
......
......@@ -5738,6 +5738,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
* NOTE: move code to surface to accomplish this
****************************************/
IWineD3DSurfaceImpl *pSrcSurface = (IWineD3DSurfaceImpl *)pSourceSurface;
IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)pDestinationSurface;
int srcWidth, srcHeight;
unsigned int srcSurfaceWidth, srcSurfaceHeight, destSurfaceWidth, destSurfaceHeight;
WINED3DFORMAT destFormat, srcFormat;
......@@ -5746,7 +5747,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
WINED3DPOOL srcPool, destPool;
int offset = 0;
int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
glDescriptor *glDescription;
const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
GLenum dummy;
int sampler;
......@@ -5779,8 +5779,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
* destination's sysmem copy. If surface conversion is needed, use BltFast instead to
* copy in sysmem and use regular surface loading.
*/
d3dfmt_get_conv((IWineD3DSurfaceImpl *) pDestinationSurface, FALSE, TRUE,
&dummy, &dummy, &dummy, &convert, &bpp, FALSE);
d3dfmt_get_conv(dst_impl, FALSE, TRUE, &dummy, &dummy, &dummy, &convert, &bpp, FALSE);
if(convert != NO_CONVERSION) {
return IWineD3DSurface_BltFast(pDestinationSurface,
pDestPoint ? pDestPoint->x : 0,
......@@ -5807,10 +5806,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
surface_internal_preload(pDestinationSurface, SRGB_RGB);
IWineD3DSurface_BindTexture(pDestinationSurface, FALSE);
glDescription = &((IWineD3DSurfaceImpl *)pDestinationSurface)->glDescription;
src_format_desc = ((IWineD3DSurfaceImpl *)pSrcSurface)->resource.format_desc;
dst_format_desc = ((IWineD3DSurfaceImpl *)pDestinationSurface)->resource.format_desc;
dst_format_desc = dst_impl->resource.format_desc;
/* this needs to be done in lines if the sourceRect != the sourceWidth */
srcWidth = pSourceRect ? pSourceRect->right - pSourceRect->left : srcSurfaceWidth;
......@@ -5833,7 +5830,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
offset += pSourceRect->top * srcSurfaceWidth * src_format_desc->byte_count;
}
TRACE("(%p) glTexSubImage2D, level %d, left %d, top %d, width %d, height %d, fmt %#x, type %#x, memory %p+%#x\n",
This, glDescription->level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
This, dst_impl->texture_level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
dst_format_desc->glType, IWineD3DSurface_GetData(pSourceSurface), offset);
/* Sanity check */
......@@ -5855,7 +5852,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
for (j = destTop; j < (srcHeight + destTop); ++j)
{
glTexSubImage2D(glDescription->target, glDescription->level, destLeft, j,
glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
data += rowoffset;
}
......@@ -5876,13 +5873,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
}
else
{
GL_EXTCALL(glCompressedTexImage2DARB(glDescription->target, glDescription->level,
GL_EXTCALL(glCompressedTexImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data));
}
}
else
{
glTexSubImage2D(glDescription->target, glDescription->level, destLeft, destTop,
glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, destTop,
srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data);
}
}
......@@ -6921,12 +6918,13 @@ static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT
surface->glRect.right = surface->pow2Width;
surface->glRect.bottom = surface->pow2Height;
if(surface->glDescription.textureName) {
if (surface->texture_name)
{
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
glDeleteTextures(1, &surface->glDescription.textureName);
glDeleteTextures(1, &surface->texture_name);
LEAVE_GL();
surface->glDescription.textureName = 0;
surface->texture_name = 0;
surface->Flags &= ~SFLAG_CLIENT;
}
if(surface->pow2Width != pPresentationParameters->BackBufferWidth ||
......
......@@ -183,7 +183,8 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
char buffer[4096];
++gen;
if ((gen % 10) == 0) {
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm", This, This->glDescription.target, This->glDescription.level, gen);
snprintf(buffer, sizeof(buffer), "/tmp/surface%p_type%u_level%u_%u.ppm",
This, This->texture_target, This->texture_level, gen);
IWineD3DSurfaceImpl_SaveSnapshot(iface, buffer);
}
/*
......
......@@ -128,9 +128,9 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
cursor.resource.pool = WINED3DPOOL_SCRATCH;
cursor.resource.format_desc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &This->wineD3DDevice->adapter->gl_info);
cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
cursor.glDescription.textureName = This->wineD3DDevice->cursorTexture;
cursor.glDescription.target = GL_TEXTURE_2D;
cursor.glDescription.level = 0;
cursor.texture_name = This->wineD3DDevice->cursorTexture;
cursor.texture_target = GL_TEXTURE_2D;
cursor.texture_level = 0;
cursor.currentDesc.Width = This->wineD3DDevice->cursorWidth;
cursor.currentDesc.Height = This->wineD3DDevice->cursorHeight;
cursor.glRect.left = 0;
......
......@@ -2029,7 +2029,8 @@ BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]
/* No oversized texture? This is easy */
if(!(This->Flags & SFLAG_OVERSIZE)) {
/* Which rect from the texture do I need? */
if(This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB) {
if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB)
{
glTexCoord[0] = (float) Rect->left;
glTexCoord[2] = (float) Rect->top;
glTexCoord[1] = (float) Rect->right;
......
......@@ -1924,14 +1924,16 @@ struct IWineD3DSurfaceImpl
/* PBO */
GLuint pbo;
GLuint texture_name;
GLuint texture_name_srgb;
GLint texture_level;
GLenum texture_target;
RECT lockedRect;
RECT dirtyRect;
int lockCount;
#define MAXLOCKCOUNT 50 /* After this amount of locks do not free the sysmem copy */
glDescriptor glDescription;
/* For GetDC */
wineD3DSurface_DIB dib;
HDC hDC;
......
......@@ -1886,13 +1886,6 @@ typedef struct _WINED3DBUFFER_DESC
UINT Size;
} WINED3DBUFFER_DESC;
typedef struct glDescriptor
{
UINT textureName, srgbTextureName;
int level;
int /*GLenum*/ target;
} glDescriptor;
typedef struct WineDirect3DStridedData
{
WINED3DFORMAT format; /* Format of the data */
......
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