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.
This commit is contained in:
Henri Verbeet 2009-07-10 10:20:13 +02:00 committed by Alexandre Julliard
parent 038d939941
commit 69b7612265
8 changed files with 142 additions and 154 deletions

View file

@ -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);

View file

@ -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 ||

View file

@ -54,11 +54,11 @@ static void surface_cleanup(IWineD3DSurfaceImpl *This)
ENTER_GL();
if (This->glDescription.textureName)
if (This->texture_name)
{
/* Release the OpenGL texture. */
TRACE("Deleting texture %u.\n", This->glDescription.textureName);
glDeleteTextures(1, &This->glDescription.textureName);
TRACE("Deleting texture %u.\n", This->texture_name);
glDeleteTextures(1, &This->texture_name);
}
if (This->Flags & SFLAG_PBO)
@ -173,7 +173,7 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type,
surface->currentDesc.Height = height;
surface->currentDesc.MultiSampleType = multisample_type;
surface->currentDesc.MultiSampleQuality = multisample_quality;
surface->glDescription.level = level;
surface->texture_level = level;
list_init(&surface->overlays);
/* Flags */
@ -254,12 +254,12 @@ void surface_set_texture_name(IWineD3DSurface *iface, GLuint new_name, BOOL srgb
if(srgb)
{
name = &This->glDescription.srgbTextureName;
name = &This->texture_name_srgb;
flag = SFLAG_INSRGBTEX;
}
else
{
name = &This->glDescription.textureName;
name = &This->texture_name;
flag = SFLAG_INTEXTURE;
}
@ -284,18 +284,18 @@ void surface_set_texture_target(IWineD3DSurface *iface, GLenum target)
TRACE("(%p) : setting target %#x\n", This, target);
if (This->glDescription.target != target)
if (This->texture_target != target)
{
if (target == GL_TEXTURE_RECTANGLE_ARB)
{
This->Flags &= ~SFLAG_NORMCOORD;
}
else if (This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB)
else if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB)
{
This->Flags |= SFLAG_NORMCOORD;
}
}
This->glDescription.target = target;
This->texture_target = target;
surface_force_reload(iface);
}
@ -360,22 +360,22 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
{
TRACE("(%p) : Calling glGetCompressedTexImageARB level %d, format %#x, type %#x, data %p.\n",
This, This->glDescription.level, format_desc->glFormat, format_desc->glType,
This, This->texture_level, format_desc->glFormat, format_desc->glType,
This->resource.allocatedMemory);
if (This->Flags & SFLAG_PBO)
{
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB");
GL_EXTCALL(glGetCompressedTexImageARB(This->glDescription.target, This->glDescription.level, NULL));
GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target, This->texture_level, NULL));
checkGLcall("glGetCompressedTexImageARB()");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
}
else
{
GL_EXTCALL(glGetCompressedTexImageARB(This->glDescription.target,
This->glDescription.level, This->resource.allocatedMemory));
GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target,
This->texture_level, This->resource.allocatedMemory));
checkGLcall("glGetCompressedTexImageARB()");
}
@ -404,22 +404,20 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
mem = This->resource.allocatedMemory;
}
TRACE("(%p) : Calling glGetTexImage level %d, format %#x, type %#x, data %p\n", This, This->glDescription.level,
format, type, mem);
TRACE("(%p) : Calling glGetTexImage level %d, format %#x, type %#x, data %p\n",
This, This->texture_level, format, type, mem);
if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB");
glGetTexImage(This->glDescription.target, This->glDescription.level, format,
type, NULL);
glGetTexImage(This->texture_target, This->texture_level, format, type, NULL);
checkGLcall("glGetTexImage()");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
} else {
glGetTexImage(This->glDescription.target, This->glDescription.level, format,
type, mem);
glGetTexImage(This->texture_target, This->texture_level, format, type, mem);
checkGLcall("glGetTexImage()");
}
LEAVE_GL();
@ -523,7 +521,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
TRACE("(%p) pbo: %#x, data: %p.\n", This, This->pbo, data);
GL_EXTCALL(glCompressedTexImage2DARB(This->glDescription.target, This->glDescription.level,
GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level,
internal, width, height, 0 /* border */, This->resource.size, NULL));
checkGLcall("glCompressedTexImage2DARB");
@ -532,7 +530,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
}
else
{
GL_EXTCALL(glCompressedTexImage2DARB(This->glDescription.target, This->glDescription.level,
GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level,
internal, width, height, 0 /* border */, This->resource.size, data));
checkGLcall("glCompressedTexSubImage2D");
}
@ -549,14 +547,14 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
checkGLcall("glBindBufferARB");
TRACE("(%p) pbo: %#x, data: %p\n", This, This->pbo, data);
glTexSubImage2D(This->glDescription.target, This->glDescription.level, 0, 0, width, height, format, type, NULL);
glTexSubImage2D(This->texture_target, This->texture_level, 0, 0, width, height, format, type, NULL);
checkGLcall("glTexSubImage2D");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
}
else {
glTexSubImage2D(This->glDescription.target, This->glDescription.level, 0, 0, width, height, format, type, data);
glTexSubImage2D(This->texture_target, This->texture_level, 0, 0, width, height, format, type, data);
checkGLcall("glTexSubImage2D");
}
@ -575,7 +573,7 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal,
if (format_desc->heightscale != 1.0f && format_desc->heightscale != 0.0f) height *= format_desc->heightscale;
TRACE("(%p) : Creating surface (target %#x) level %d, d3d format %s, internal format %#x, width %d, height %d, gl format %#x, gl type=%#x\n",
This, This->glDescription.target, This->glDescription.level, debug_d3dformat(format_desc->format),
This, This->texture_target, This->texture_level, debug_d3dformat(format_desc->format),
internal, width, height, format, type);
if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
@ -591,8 +589,8 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal,
This->Flags |= SFLAG_CLIENT;
mem = (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
ENTER_GL();
GL_EXTCALL(glCompressedTexImage2DARB(This->glDescription.target, This->glDescription.level, internal,
width, height, 0 /* border */, This->resource.size, mem));
GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level, internal,
width, height, 0 /* border */, This->resource.size, mem));
LEAVE_GL();
}
@ -623,7 +621,7 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal,
mem = (BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
}
}
glTexImage2D(This->glDescription.target, This->glDescription.level, internal, width, height, 0, format, type, mem);
glTexImage2D(This->texture_target, This->texture_level, internal, width, height, 0, format, type, mem);
checkGLcall("glTexImage2D");
if(enable_client_storage) {
@ -808,7 +806,7 @@ void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb)
GLclampf tmp;
tmp = 0.9f;
ENTER_GL();
glPrioritizeTextures(1, &This->glDescription.textureName, &tmp);
glPrioritizeTextures(1, &This->texture_name, &tmp);
LEAVE_GL();
}
}
@ -899,10 +897,10 @@ static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **) &texture);
if(!texture) {
ENTER_GL();
glDeleteTextures(1, &This->glDescription.textureName);
This->glDescription.textureName = 0;
glDeleteTextures(1, &This->glDescription.srgbTextureName);
This->glDescription.srgbTextureName = 0;
glDeleteTextures(1, &This->texture_name);
This->texture_name = 0;
glDeleteTextures(1, &This->texture_name_srgb);
This->texture_name_srgb = 0;
LEAVE_GL();
} else {
IWineD3DBaseTexture_Release(texture);
@ -1217,18 +1215,15 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
* this code from getting called in such cases or perhaps
* we can use FBOs */
glCopyTexSubImage2D(This->glDescription.target,
This->glDescription.level,
0, 0, 0, 0,
This->currentDesc.Width,
This->currentDesc.Height);
glCopyTexSubImage2D(This->texture_target, This->texture_level,
0, 0, 0, 0, This->currentDesc.Width, This->currentDesc.Height);
checkGLcall("glCopyTexSubImage2D");
glReadBuffer(prevRead);
checkGLcall("glReadBuffer");
LEAVE_GL();
TRACE("Updated target %d\n", This->glDescription.target);
TRACE("Updated target %d\n", This->texture_target);
}
static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) {
@ -2483,7 +2478,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
{
TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n");
ENTER_GL();
GL_EXTCALL(glColorTableEXT(This->glDescription.target,GL_RGBA,256,GL_RGBA,GL_UNSIGNED_BYTE, table));
GL_EXTCALL(glColorTableEXT(This->texture_target, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, table));
LEAVE_GL();
}
else
@ -2532,7 +2527,7 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0));
/* Rebind the texture because it isn't bound anymore */
glBindTexture(This->glDescription.target, This->glDescription.textureName);
glBindTexture(This->texture_target, This->texture_name);
LEAVE_GL();
}
@ -2608,7 +2603,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BO
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);
}
/*
@ -2647,30 +2643,31 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL
GLuint *name;
TRACE("(%p) : Binding surface\n", This);
name = srgb ? &This->glDescription.srgbTextureName : &This->glDescription.textureName;
name = srgb ? &This->texture_name_srgb : &This->texture_name;
if(!device->isInDraw) {
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
}
ENTER_GL();
if (!This->glDescription.level) {
if (!This->texture_level)
{
if (!*name) {
glGenTextures(1, name);
checkGLcall("glGenTextures");
TRACE("Surface %p given name %d\n", This, *name);
glBindTexture(This->glDescription.target, *name);
glBindTexture(This->texture_target, *name);
checkGLcall("glBindTexture");
glTexParameteri(This->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
glTexParameteri(This->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
glTexParameteri(This->glDescription.target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE)");
glTexParameteri(This->glDescription.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(This->texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
glTexParameteri(This->glDescription.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(This->texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
}
/* This is where we should be reducing the amount of GLMemoryUsed */
@ -2679,7 +2676,7 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL
ERR("Mipmap surface has a glTexture bound to it!\n");
}
glBindTexture(This->glDescription.target, *name);
glBindTexture(This->texture_target, *name);
checkGLcall("glBindTexture");
LEAVE_GL();
@ -2762,12 +2759,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, c
}
allocatedMemory = HeapAlloc(GetProcessHeap(), 0, width * height * 4);
ENTER_GL();
FIXME("Saving texture level %d width %d height %d\n", This->glDescription.level, width, height);
glGetTexImage(GL_TEXTURE_2D,
This->glDescription.level,
GL_RGBA,
GL_UNSIGNED_INT_8_8_8_8_REV,
allocatedMemory);
FIXME("Saving texture level %d width %d height %d\n", This->texture_level, width, height);
glGetTexImage(GL_TEXTURE_2D, This->texture_level, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, allocatedMemory);
checkGLcall("glTexImage2D");
if (tmpTexture) {
glBindTexture(GL_TEXTURE_2D, 0);
@ -2969,9 +2962,15 @@ void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) {
/* Flip the opengl texture */
{
glDescriptor tmp_desc = back->glDescription;
back->glDescription = front->glDescription;
front->glDescription = tmp_desc;
GLuint tmp;
tmp = back->texture_name;
back->texture_name = front->texture_name;
front->texture_name = tmp;
tmp = back->texture_name_srgb;
back->texture_name_srgb = front->texture_name_srgb;
front->texture_name_srgb = tmp;
}
{
@ -3058,7 +3057,7 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
ENTER_GL();
/* Bind the target texture */
glBindTexture(This->glDescription.target, This->glDescription.textureName);
glBindTexture(This->texture_target, This->texture_name);
checkGLcall("glBindTexture");
if(!swapchain) {
TRACE("Reading from an offscreen target\n");
@ -3093,11 +3092,10 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
{
/* Upside down copy without stretching is nice, one glCopyTexSubImage call will do */
glCopyTexSubImage2D(This->glDescription.target,
This->glDescription.level,
drect->x1, drect->y1, /* xoffset, yoffset */
srect->x1, Src->currentDesc.Height - srect->y2,
drect->x2 - drect->x1, drect->y2 - drect->y1);
glCopyTexSubImage2D(This->texture_target, This->texture_level,
drect->x1 /*xoffset */, drect->y1 /* y offset */,
srect->x1, Src->currentDesc.Height - srect->y2,
drect->x2 - drect->x1, drect->y2 - drect->y1);
} else {
UINT yoffset = Src->currentDesc.Height - srect->y1 + drect->y1 - 1;
/* I have to process this row by row to swap the image,
@ -3115,18 +3113,14 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
UINT col;
for(col = drect->x1; col < drect->x2; col++) {
glCopyTexSubImage2D(This->glDescription.target,
This->glDescription.level,
drect->x1 + col, row, /* xoffset, yoffset */
srect->x1 + col * xrel, yoffset - (int) (row * yrel),
1, 1);
glCopyTexSubImage2D(This->texture_target, This->texture_level,
drect->x1 + col /* x offset */, row /* y offset */,
srect->x1 + col * xrel, yoffset - (int) (row * yrel), 1, 1);
}
} else {
glCopyTexSubImage2D(This->glDescription.target,
This->glDescription.level,
drect->x1, row, /* xoffset, yoffset */
srect->x1, yoffset - (int) (row * yrel),
drect->x2-drect->x1, 1);
glCopyTexSubImage2D(This->texture_target, This->texture_level,
drect->x1 /* x offset */, row /* y offset */,
srect->x1, yoffset - (int) (row * yrel), drect->x2-drect->x1, 1);
}
}
}
@ -3156,7 +3150,8 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
surface_internal_preload((IWineD3DSurface *) This, SRGB_RGB);
noBackBufferBackup = !swapchain && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
if(!noBackBufferBackup && Src->glDescription.textureName == 0) {
if (!noBackBufferBackup && !Src->texture_name)
{
/* Get it a description */
surface_internal_preload(SrcSurface, SRGB_RGB);
}
@ -3177,15 +3172,15 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
glGenTextures(1, &backup);
checkGLcall("glGenTextures");
glBindTexture(GL_TEXTURE_2D, backup);
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)");
texture_target = GL_TEXTURE_2D;
} else {
/* 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
*/
texture_target = Src->glDescription.target;
glBindTexture(texture_target, Src->glDescription.textureName);
checkGLcall("glBindTexture(texture_target, Src->glDescription.textureName)");
texture_target = Src->texture_target;
glBindTexture(texture_target, Src->texture_name);
checkGLcall("glBindTexture(texture_target, Src->texture_name)");
glEnable(texture_target);
checkGLcall("glEnable(texture_target)");
@ -3219,7 +3214,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
checkGLcall("glTexParameteri");
if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
src = backup ? backup : Src->glDescription.textureName;
src = backup ? backup : Src->texture_name;
} else {
glReadBuffer(GL_FRONT);
checkGLcall("glReadBuffer(GL_FRONT)");
@ -3301,14 +3296,15 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
glEnd();
checkGLcall("glEnd and previous");
if(texture_target != This->glDescription.target) {
if (texture_target != This->texture_target)
{
glDisable(texture_target);
glEnable(This->glDescription.target);
texture_target = This->glDescription.target;
glEnable(This->texture_target);
texture_target = This->texture_target;
}
/* Now read the stretched and upside down image into the destination texture */
glBindTexture(texture_target, This->glDescription.textureName);
glBindTexture(texture_target, This->texture_name);
checkGLcall("glBindTexture");
glCopyTexSubImage2D(texture_target,
0,
@ -3328,13 +3324,14 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
glBindTexture(GL_TEXTURE_2D, backup);
checkGLcall("glBindTexture(GL_TEXTURE_2D, backup)");
} else {
if(texture_target != Src->glDescription.target) {
if (texture_target != Src->texture_target)
{
glDisable(texture_target);
glEnable(Src->glDescription.target);
texture_target = Src->glDescription.target;
glEnable(Src->texture_target);
texture_target = Src->texture_target;
}
glBindTexture(Src->glDescription.target, Src->glDescription.textureName);
checkGLcall("glBindTexture(Src->glDescription.target, Src->glDescription.textureName)");
glBindTexture(Src->texture_target, Src->texture_name);
checkGLcall("glBindTexture(Src->texture_target, Src->texture_name)");
}
glBegin(GL_QUADS);
@ -3362,7 +3359,8 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
checkGLcall("glDisable(texture_target)");
/* Cleanup */
if(src != Src->glDescription.textureName && src != backup) {
if (src != Src->texture_name && src != backup)
{
glDeleteTextures(1, &src);
checkGLcall("glDeleteTextures(1, &src)");
}
@ -3762,23 +3760,21 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
}
myDevice->blitter->set_shader((IWineD3DDevice *) myDevice, Src->resource.format_desc,
Src->glDescription.target, Src->pow2Width, Src->pow2Height);
Src->texture_target, Src->pow2Width, Src->pow2Height);
ENTER_GL();
/* Bind the texture */
glBindTexture(Src->glDescription.target, Src->glDescription.textureName);
glBindTexture(Src->texture_target, Src->texture_name);
checkGLcall("glBindTexture");
/* Filtering for StretchRect */
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MAG_FILTER,
magLookup[Filter - WINED3DTEXF_NONE]);
glTexParameteri(Src->texture_target, GL_TEXTURE_MAG_FILTER, magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
glTexParameteri(Src->texture_target, GL_TEXTURE_MIN_FILTER, minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(Src->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(Src->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi");
@ -3825,8 +3821,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
checkGLcall("glDisable(GL_ALPHA_TEST)");
}
glBindTexture(Src->glDescription.target, 0);
checkGLcall("glBindTexture(Src->glDescription.target, 0)");
glBindTexture(Src->texture_target, 0);
checkGLcall("glBindTexture(Src->texture_target, 0)");
/* Restore the color key parameters */
Src->CKeyFlags = oldCKeyFlags;
@ -4136,8 +4132,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
unsigned int pow2Width, pow2Height;
This->glDescription.textureName = 0;
This->glDescription.target = GL_TEXTURE_2D;
This->texture_name = 0;
This->texture_target = GL_TEXTURE_2D;
/* Non-power2 support */
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || GL_SUPPORT(WINE_NORMALIZED_TEXRECT)) {
@ -4195,7 +4191,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
&& (wined3d_settings.rendertargetlock_mode == RTL_READTEX
|| wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
{
This->glDescription.target = GL_TEXTURE_RECTANGLE_ARB;
This->texture_target = GL_TEXTURE_RECTANGLE_ARB;
This->pow2Width = This->currentDesc.Width;
This->pow2Height = This->currentDesc.Height;
This->Flags &= ~(SFLAG_NONPOW2 | SFLAG_NORMCOORD);
@ -4409,7 +4405,8 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) {
/* Note that we use depth_blt here as well, rather than glCopyTexImage2D
* directly on the FBO texture. That's because we need to flip. */
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
if (This->glDescription.target == GL_TEXTURE_RECTANGLE_ARB) {
if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB)
{
glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
bind_target = GL_TEXTURE_RECTANGLE_ARB;
} else {
@ -4417,14 +4414,8 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) {
bind_target = GL_TEXTURE_2D;
}
glBindTexture(bind_target, device->depth_blt_texture);
glCopyTexImage2D(bind_target,
This->glDescription.level,
This->resource.format_desc->glInternal,
0,
0,
This->currentDesc.Width,
This->currentDesc.Height,
0);
glCopyTexImage2D(bind_target, This->texture_level, This->resource.format_desc->glInternal,
0, 0, This->currentDesc.Width, This->currentDesc.Height, 0);
glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(bind_target, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
@ -4473,7 +4464,8 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) {
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
checkGLcall("glBindFramebuffer()");
surface_depth_blt(This, This->glDescription.textureName, This->currentDesc.Width, This->currentDesc.Height, This->glDescription.target);
surface_depth_blt(This, This->texture_name, This->currentDesc.Width,
This->currentDesc.Height, This->texture_target);
checkGLcall("depth_blt");
if (device->activeContext->current_fbo) {
@ -4582,7 +4574,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
rect.bottom = This->currentDesc.Height;
}
switch(This->glDescription.target)
switch (This->texture_target)
{
case GL_TEXTURE_2D:
bind_target = GL_TEXTURE_2D;
@ -4667,7 +4659,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
break;
default:
ERR("Unexpected texture target %#x\n", This->glDescription.target);
ERR("Unexpected texture target %#x\n", This->texture_target);
return;
}
@ -4676,8 +4668,8 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
glEnable(bind_target);
checkGLcall("glEnable(bind_target)");
glBindTexture(bind_target, This->glDescription.textureName);
checkGLcall("bind_target, This->glDescription.textureName)");
glBindTexture(bind_target, This->texture_name);
checkGLcall("bind_target, This->texture_name)");
glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri");
glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

View file

@ -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);
}
/*

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 */