return FALSE;
}
-#undef GLINFO_LOCATION
-
-#define GLINFO_LOCATION This->resource.device->adapter->gl_info
-
/* This call just downloads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
-static void surface_download_data(IWineD3DSurfaceImpl *This) {
+static void surface_download_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
+{
const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
/* Only support read back of converted P8 surfaces */
/* This call just uploads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
-static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data) {
+static void surface_upload_data(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+ GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data)
+{
const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
TRACE("This %p, internal %#x, width %d, height %d, format %#x, type %#x, data %p.\n",
/* This call just allocates the texture, the caller is responsible for binding
* the correct texture. */
/* Context activation is done by the caller. */
-static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) {
- const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info;
+static void surface_allocate_surface(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+ GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type)
+{
const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
BOOL enable_client_storage = FALSE;
const BYTE *mem = NULL;
}
/* Context activation is done by the caller. */
-static void surface_remove_pbo(IWineD3DSurfaceImpl *This) {
+static void surface_remove_pbo(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info)
+{
This->resource.heapMemory = HeapAlloc(GetProcessHeap() ,0 , This->resource.size + RESOURCE_ALIGNMENT);
This->resource.allocatedMemory =
(BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
gl_info = context->gl_info;
/* Destroy PBOs, but load them into real sysmem before */
- if(This->Flags & SFLAG_PBO) {
- surface_remove_pbo(This);
- }
+ if (This->Flags & SFLAG_PBO)
+ surface_remove_pbo(This, gl_info);
/* Destroy fbo render buffers. This is needed for implicit render targets, for
* all application-created targets the application has to release the surface
static void read_from_framebuffer(IWineD3DSurfaceImpl *This, const RECT *rect, void *dest, UINT pitch)
{
IWineD3DDeviceImpl *myDevice = This->resource.device;
+ const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
BYTE *mem;
GLint fmt;
* context->last_was_blit set on the unlock.
*/
context = context_acquire(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
+ gl_info = context->gl_info;
+
ENTER_GL();
/* Select the correct read buffer, and give some debug output.
static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb)
{
IWineD3DDeviceImpl *device = This->resource.device;
+ const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
int bpp;
GLenum format, internal, type;
* states in the stateblock, and no driver was found yet that had bugs in that regard.
*/
context = context_acquire(device, (IWineD3DSurface *) This, CTXUSAGE_RESOURCELOAD);
+ gl_info = context->gl_info;
+
surface_bind_and_dirtify(This, srgb);
ENTER_GL();
LEAVE_GL();
}
- if(!(This->Flags & alloc_flag)) {
- surface_allocate_surface(This, internal, This->pow2Width,
- This->pow2Height, format, type);
+ if (!(This->Flags & alloc_flag))
+ {
+ surface_allocate_surface(This, gl_info, internal, This->pow2Width, This->pow2Height, format, type);
This->Flags |= alloc_flag;
}
}
/* Context activation is done by the caller. */
-void surface_prepare_texture(IWineD3DSurfaceImpl *surface, BOOL srgb)
+void surface_prepare_texture(IWineD3DSurfaceImpl *surface, const struct wined3d_gl_info *gl_info, BOOL srgb)
{
DWORD alloc_flag = srgb ? SFLAG_SRGBALLOCATED : SFLAG_ALLOCATED;
GLenum format, internal, type;
}
surface_bind_and_dirtify(surface, srgb);
- surface_allocate_surface(surface, internal, width, height, format, type);
+ surface_allocate_surface(surface, gl_info, internal, width, height, format, type);
surface->Flags |= alloc_flag;
}
lock_end:
if (This->Flags & SFLAG_PBO)
{
+ const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
context = context_acquire(myDevice, NULL, CTXUSAGE_RESOURCELOAD);
+ gl_info = context->gl_info;
+
ENTER_GL();
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB");
GLint skipBytes = 0;
UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This); /* target is argb, 4 byte */
IWineD3DDeviceImpl *myDevice = This->resource.device;
+ const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
/* Activate the correct context for the render target */
context = context_acquire(myDevice, (IWineD3DSurface *) This, CTXUSAGE_BLIT);
+ gl_info = context->gl_info;
+
ENTER_GL();
if (!surface_is_offscreen((IWineD3DSurface *)This))
if (This->Flags & SFLAG_PBO)
{
+ const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
TRACE("Freeing PBO memory\n");
context = context_acquire(myDevice, NULL, CTXUSAGE_RESOURCELOAD);
+ gl_info = context->gl_info;
+
ENTER_GL();
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB));
extensions like ATI_fragment_shaders is possible.
*/
/* Context activation is done by the caller. */
-static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert) {
+static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface,
+ const struct wined3d_gl_info *gl_info, CONVERT_TYPES convert)
+{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
BYTE table[256][4];
IWineD3DDeviceImpl *device = This->resource.device;
- const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK));
/* Re-upload the palette */
context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
- d3dfmt_p8_upload_palette(iface, convert);
+ d3dfmt_p8_upload_palette(iface, context->gl_info, convert);
context_release(context);
} else {
if(!(This->Flags & SFLAG_INSYSMEM)) {
}
/* GL locking is done by the caller */
-static void surface_depth_blt(IWineD3DSurfaceImpl *This, GLuint texture, GLsizei w, GLsizei h, GLenum target)
+static void surface_depth_blt(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info,
+ GLuint texture, GLsizei w, GLsizei h, GLenum target)
{
IWineD3DDeviceImpl *device = This->resource.device;
struct blt_info info;
context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, iface, FALSE);
/* Do the actual blit */
- surface_depth_blt(This, device->depth_blt_texture, This->currentDesc.Width, This->currentDesc.Height, bind_target);
+ surface_depth_blt(This, gl_info, device->depth_blt_texture,
+ This->currentDesc.Width, This->currentDesc.Height, bind_target);
checkGLcall("depth_blt");
if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id);
ENTER_GL();
context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
- surface_depth_blt(This, This->texture_name, This->currentDesc.Width,
- This->currentDesc.Height, This->texture_target);
+ surface_depth_blt(This, gl_info, This->texture_name,
+ This->currentDesc.Width, This->currentDesc.Height, This->texture_target);
checkGLcall("depth_blt");
if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id);
if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
surface_bind_and_dirtify(This, !(This->Flags & SFLAG_INTEXTURE));
- surface_download_data(This);
+ surface_download_data(This, gl_info);
if (context) context_release(context);
}
TRACE("Removing the pbo attached to surface %p\n", This);
if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
- surface_remove_pbo(This);
+ surface_remove_pbo(This, gl_info);
if (context) context_release(context);
}
if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
- surface_prepare_texture(This, srgb);
+ surface_prepare_texture(This, gl_info, srgb);
surface_bind_and_dirtify(This, srgb);
if(This->CKeyFlags & WINEDDSD_CKSRCBLT) {
* but it isn't set (yet) in all cases it is getting called. */
if((convert != NO_CONVERSION) && (This->Flags & SFLAG_PBO)) {
TRACE("Removing the pbo attached to surface %p\n", This);
- surface_remove_pbo(This);
+ surface_remove_pbo(This, gl_info);
}
if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
&& (gl_info->supported[EXT_PALETTED_TEXTURE] || device->blitter->color_fixup_supported(This->resource.format_desc->color_fixup)))
{
- d3dfmt_p8_upload_palette(iface, convert);
+ d3dfmt_p8_upload_palette(iface, gl_info, convert);
mem = This->resource.allocatedMemory;
} else {
mem = This->resource.allocatedMemory;
if (This->Flags & SFLAG_NONPOW2) {
TRACE("non power of two support\n");
- if (mem || (This->Flags & SFLAG_PBO)) {
- surface_upload_data(This, internal, This->currentDesc.Width, This->currentDesc.Height, format, type, mem);
+ if (mem || (This->Flags & SFLAG_PBO))
+ {
+ surface_upload_data(This, gl_info, internal,
+ This->currentDesc.Width, This->currentDesc.Height, format, type, mem);
}
} else {
/* When making the realloc conditional, keep in mind that GL_APPLE_client_storage may be in use, and This->resource.allocatedMemory
* changed. So also keep track of memory changes. In this case the texture has to be reallocated
*/
- if (mem || (This->Flags & SFLAG_PBO)) {
- surface_upload_data(This, internal, This->glRect.right - This->glRect.left, This->glRect.bottom - This->glRect.top, format, type, mem);
+ if (mem || (This->Flags & SFLAG_PBO))
+ {
+ surface_upload_data(This, gl_info, internal, This->glRect.right - This->glRect.left,
+ This->glRect.bottom - This->glRect.top, format, type, mem);
}
}
IWineD3DSurfaceImpl_GetImplType,
IWineD3DSurfaceImpl_DrawOverlay
};
-#undef GLINFO_LOCATION
-#define GLINFO_LOCATION device->adapter->gl_info
static HRESULT ffp_blit_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
/* Context activation is done by the caller. */
static void ffp_blit_free(IWineD3DDevice *iface) { }