Commit 78984cf4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of ENTER_GL / LEAVE_GL.

parent fc50e2b7
......@@ -29,7 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
/* GL locking for state handlers is done by the caller. */
/* Context activation for state handlers is done by the caller. */
/* Some private defines, Constant associations, etc.
* Env bump matrix and per stage constant should be independent,
......@@ -1085,7 +1085,7 @@ static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
/* Context activation and GL locking are done by the caller. */
/* Context activation is done by the caller. */
static void atifs_enable(const struct wined3d_gl_info *gl_info, BOOL enable)
{
if (enable)
......@@ -1173,11 +1173,9 @@ static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *context)
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct atifs_ffp_desc *entry_ati = WINE_RB_ENTRY_VALUE(entry, struct atifs_ffp_desc, parent.entry);
ENTER_GL();
GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati->shader));
checkGLcall("glDeleteFragmentShaderATI(entry->shader)");
HeapFree(GetProcessHeap(), 0, entry_ati);
LEAVE_GL();
}
/* Context activation is done by the caller. */
......
......@@ -98,10 +98,8 @@ static void delete_gl_buffer(struct wined3d_buffer *This, const struct wined3d_g
{
if(!This->buffer_object) return;
ENTER_GL();
GL_EXTCALL(glDeleteBuffersARB(1, &This->buffer_object));
checkGLcall("glDeleteBuffersARB");
LEAVE_GL();
This->buffer_object = 0;
if(This->query)
......@@ -120,8 +118,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
TRACE("Creating an OpenGL vertex buffer object for wined3d_buffer %p with usage %s.\n",
This, debug_d3dusage(This->resource.usage));
ENTER_GL();
/* Make sure that the gl error is cleared. Do not use checkGLcall
* here because checkGLcall just prints a fixme and continues. However,
* if an error during VBO creation occurs we can fall back to non-vbo operation
......@@ -140,7 +136,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
if (!This->buffer_object || error != GL_NO_ERROR)
{
ERR("Failed to create a VBO with error %s (%#x)\n", debug_glerror(error), error);
LEAVE_GL();
goto fail;
}
......@@ -151,7 +146,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
if (error != GL_NO_ERROR)
{
ERR("Failed to bind the VBO with error %s (%#x)\n", debug_glerror(error), error);
LEAVE_GL();
goto fail;
}
......@@ -188,7 +182,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, const struc
*/
GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, This->resource.allocatedMemory, gl_usage));
error = gl_info->gl_ops.gl.p_glGetError();
LEAVE_GL();
if (error != GL_NO_ERROR)
{
ERR("glBufferDataARB failed with error %s (%#x)\n", debug_glerror(error), error);
......@@ -516,10 +509,8 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_inf
if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
device_invalidate_state(This->resource.device, STATE_INDEXBUFFER);
ENTER_GL();
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
GL_EXTCALL(glGetBufferSubDataARB(This->buffer_type_hint, 0, This->resource.size, This->resource.allocatedMemory));
LEAVE_GL();
This->flags |= WINED3D_BUFFER_DOUBLEBUFFER;
return This->resource.allocatedMemory;
......@@ -610,10 +601,8 @@ static void buffer_sync_apple(struct wined3d_buffer *This, DWORD flags, const st
if (flags & WINED3D_MAP_DISCARD)
{
ENTER_GL();
GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->resource.size, NULL, This->buffer_object_usage));
checkGLcall("glBufferDataARB\n");
LEAVE_GL();
return;
}
......@@ -664,10 +653,8 @@ drop_query:
}
gl_info->gl_ops.gl.p_glFinish();
ENTER_GL();
GL_EXTCALL(glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE));
checkGLcall("glBufferParameteriAPPLE(This->buffer_type_hint, GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE)");
LEAVE_GL();
This->flags &= ~WINED3D_BUFFER_APPLESYNC;
}
......@@ -677,8 +664,6 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
BYTE *map;
UINT start = 0, len = 0;
ENTER_GL();
/* This potentially invalidates the element array buffer binding, but the
* caller always takes care of this. */
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
......@@ -704,16 +689,13 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
syncflags |= WINED3D_MAP_DISCARD;
if (flags & WINED3D_BUFFER_NOSYNC)
syncflags |= WINED3D_MAP_NOOVERWRITE;
LEAVE_GL();
buffer_sync_apple(This, syncflags, gl_info);
ENTER_GL();
}
map = GL_EXTCALL(glMapBufferARB(This->buffer_type_hint, GL_WRITE_ONLY_ARB));
checkGLcall("glMapBufferARB");
}
if (!map)
{
LEAVE_GL();
ERR("Failed to map opengl buffer\n");
return;
}
......@@ -739,8 +721,6 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
}
GL_EXTCALL(glUnmapBufferARB(This->buffer_type_hint));
checkGLcall("glUnmapBufferARB");
LEAVE_GL();
}
/* Do not call while under the GL lock. */
......@@ -938,12 +918,10 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
}
}
ENTER_GL();
GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
checkGLcall("glBindBufferARB");
GL_EXTCALL(glBufferSubDataARB(buffer->buffer_type_hint, start, len, data + start));
checkGLcall("glBufferSubDataARB");
LEAVE_GL();
}
HeapFree(GetProcessHeap(), 0, data);
......@@ -1048,8 +1026,6 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
context = context_acquire(device, NULL);
gl_info = context->gl_info;
ENTER_GL();
if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
context_invalidate_state(context, STATE_INDEXBUFFER);
GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
......@@ -1064,25 +1040,18 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
else
{
if (buffer->flags & WINED3D_BUFFER_APPLESYNC)
{
LEAVE_GL();
buffer_sync_apple(buffer, flags, gl_info);
ENTER_GL();
}
buffer->resource.allocatedMemory = GL_EXTCALL(glMapBufferARB(buffer->buffer_type_hint,
GL_READ_WRITE_ARB));
checkGLcall("glMapBufferARB");
}
LEAVE_GL();
if (((DWORD_PTR)buffer->resource.allocatedMemory) & (RESOURCE_ALIGNMENT - 1))
{
WARN("Pointer %p is not %u byte aligned.\n", buffer->resource.allocatedMemory, RESOURCE_ALIGNMENT);
ENTER_GL();
GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
checkGLcall("glUnmapBufferARB");
LEAVE_GL();
buffer->resource.allocatedMemory = NULL;
if (buffer->resource.usage & WINED3DUSAGE_DYNAMIC)
......@@ -1168,8 +1137,6 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
context = context_acquire(device, NULL);
gl_info = context->gl_info;
ENTER_GL();
if (buffer->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
context_invalidate_state(context, STATE_INDEXBUFFER);
GL_EXTCALL(glBindBufferARB(buffer->buffer_type_hint, buffer->buffer_object));
......@@ -1194,7 +1161,6 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
}
GL_EXTCALL(glUnmapBufferARB(buffer->buffer_type_hint));
LEAVE_GL();
if (wined3d_settings.strict_draw_ordering)
gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
context_release(context);
......
......@@ -710,8 +710,6 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
return;
}
ENTER_GL();
/* Only set the values up once, as they are not changing. */
if (flags & WINED3DCLEAR_STENCIL)
{
......@@ -816,8 +814,6 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
}
}
LEAVE_GL();
if (wined3d_settings.strict_draw_ordering || (flags & WINED3DCLEAR_TARGET
&& target->container.type == WINED3D_CONTAINER_SWAPCHAIN
&& target->container.u.swapchain->front_buffer == target))
......@@ -978,7 +974,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
* OpenGL will only allow that when a valid texture is bound.
* We emulate this by creating dummy textures and binding them
* to each texture stage when the currently set D3D texture is NULL. */
ENTER_GL();
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
......@@ -1057,8 +1052,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
LEAVE_GL();
}
/* Context activation is done by the caller. */
......@@ -1066,7 +1059,6 @@ static void destroy_dummy_textures(struct wined3d_device *device, const struct w
{
unsigned int count = min(MAX_COMBINED_SAMPLERS, gl_info->limits.combined_samplers);
ENTER_GL();
if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
{
gl_info->gl_ops.gl.p_glDeleteTextures(count, device->dummy_texture_cube);
......@@ -1087,7 +1079,6 @@ static void destroy_dummy_textures(struct wined3d_device *device, const struct w
gl_info->gl_ops.gl.p_glDeleteTextures(count, device->dummy_texture_2d);
checkGLcall("glDeleteTextures(count, device->dummy_texture_2d)");
LEAVE_GL();
memset(device->dummy_texture_cube, 0, gl_info->limits.textures * sizeof(*device->dummy_texture_cube));
memset(device->dummy_texture_3d, 0, gl_info->limits.textures * sizeof(*device->dummy_texture_3d));
......@@ -1297,8 +1288,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
create_dummy_textures(device, context);
ENTER_GL();
/* Initialize the current view state */
device->view_ident = 1;
device->contexts[0]->last_was_rhw = 0;
......@@ -1325,7 +1314,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
}
TRACE("All defaults now set up, leaving 3D init.\n");
LEAVE_GL();
context_release(context);
......@@ -1438,9 +1426,7 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
/* Delete the mouse cursor texture */
if (device->cursorTexture)
{
ENTER_GL();
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->cursorTexture);
LEAVE_GL();
device->cursorTexture = 0;
}
......@@ -1449,9 +1435,7 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
*/
if (device->depth_blt_texture)
{
ENTER_GL();
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->depth_blt_texture);
LEAVE_GL();
device->depth_blt_texture = 0;
}
......@@ -3657,10 +3641,8 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer;
e->data.buffer_object = 0;
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
ENTER_GL();
GL_EXTCALL(glDeleteBuffersARB(1, &vb->buffer_object));
vb->buffer_object = 0;
LEAVE_GL();
}
if (e->data.addr)
e->data.addr += e->stride * src_start_idx;
......@@ -4970,9 +4952,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
if (device->cursorTexture)
{
struct wined3d_context *context = context_acquire(device, NULL);
ENTER_GL();
context->gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->cursorTexture);
LEAVE_GL();
context_release(context);
device->cursorTexture = 0;
}
......@@ -5037,8 +5017,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
context = context_acquire(device, NULL);
ENTER_GL();
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
......@@ -5061,8 +5039,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
}
LEAVE_GL();
context_release(context);
}
else
......@@ -5219,7 +5195,6 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d
device->shader_backend->shader_destroy(shader);
}
ENTER_GL();
if (device->depth_blt_texture)
{
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->depth_blt_texture);
......@@ -5230,7 +5205,6 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d
gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->cursorTexture);
device->cursorTexture = 0;
}
LEAVE_GL();
device->blitter->free_private(device);
device->shader_backend->shader_free_private(device);
......
......@@ -412,8 +412,8 @@ ULONG CDECL wined3d_decref(struct wined3d *wined3d)
return refcount;
}
/* GL locking is done by the caller */
static inline BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
/* Context activation is done by the caller. */
static BOOL test_arb_vs_offset_limit(const struct wined3d_gl_info *gl_info)
{
GLuint prog;
BOOL ret = FALSE;
......@@ -523,8 +523,6 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
/* No PBO -> No point in testing them. */
if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return;
ENTER_GL();
while (gl_info->gl_ops.gl.p_glGetError());
gl_info->gl_ops.gl.p_glGenTextures(1, &texture);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, texture);
......@@ -542,12 +540,10 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
checkGLcall("Loading the PBO test texture");
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
LEAVE_GL();
gl_info->gl_ops.gl.p_glFinish(); /* just to be sure */
memset(check, 0, sizeof(check));
ENTER_GL();
gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, check);
checkGLcall("Reading back the PBO test texture");
......@@ -555,8 +551,6 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info)
GL_EXTCALL(glDeleteBuffersARB(1, &pbo));
checkGLcall("PBO test cleanup");
LEAVE_GL();
if (memcmp(check, pattern, sizeof(check)))
{
WARN("PBO test failed, read back data doesn't match original.\n"
......@@ -613,11 +607,9 @@ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const
if (!gl_info->supported[EXT_SECONDARY_COLOR])
return FALSE;
ENTER_GL();
while (gl_info->gl_ops.gl.p_glGetError());
GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE, 4, data);
error = gl_info->gl_ops.gl.p_glGetError();
LEAVE_GL();
if (error == GL_NO_ERROR)
{
......@@ -648,14 +640,12 @@ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const ch
if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE;
ENTER_GL();
while (gl_info->gl_ops.gl.p_glGetError());
GL_EXTCALL(glGenProgramsARB(1, &prog));
if(!prog)
{
ERR("Failed to create the NVvp clip test program\n");
LEAVE_GL();
return FALSE;
}
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prog));
......@@ -675,7 +665,6 @@ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const ch
GL_EXTCALL(glDeleteProgramsARB(1, &prog));
checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
LEAVE_GL();
return ret;
}
......@@ -691,8 +680,6 @@ static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const ch
memset(data, 0xcc, sizeof(data));
ENTER_GL();
gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
......@@ -729,8 +716,6 @@ static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, const ch
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
checkGLcall("glDeleteTextures");
LEAVE_GL();
return *(DWORD *)data == 0x11111111;
}
......@@ -743,8 +728,6 @@ static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const cha
GLuint tex;
GLint size;
ENTER_GL();
gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
......@@ -759,8 +742,6 @@ static BOOL match_broken_rgba16(const struct wined3d_gl_info *gl_info, const cha
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
checkGLcall("glDeleteTextures");
LEAVE_GL();
return size < 16;
}
......@@ -2608,13 +2589,10 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
TRACE("adapter %p.\n", adapter);
ENTER_GL();
gl_renderer_str = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER);
TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str));
if (!gl_renderer_str)
{
LEAVE_GL();
ERR("Received a NULL GL_RENDERER.\n");
return FALSE;
}
......@@ -2623,7 +2601,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str));
if (!gl_vendor_str)
{
LEAVE_GL();
ERR("Received a NULL GL_VENDOR.\n");
return FALSE;
}
......@@ -2633,7 +2610,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str));
if (!gl_version_str)
{
LEAVE_GL();
ERR("Received a NULL GL_VERSION.\n");
return FALSE;
}
......@@ -2643,13 +2619,10 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
GL_Extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS);
if (!GL_Extensions)
{
LEAVE_GL();
ERR("Received a NULL GL_EXTENSIONS.\n");
return FALSE;
}
LEAVE_GL();
memset(gl_info->supported, 0, sizeof(gl_info->supported));
gl_info->supported[WINED3D_GL_EXT_NONE] = TRUE;
......@@ -2792,8 +2765,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
gl_info->supported[ARB_FRAMEBUFFER_SRGB] = FALSE;
}
ENTER_GL();
wined3d_adapter_init_limits(gl_info);
if (gl_info->supported[ARB_VERTEX_PROGRAM] && test_arb_vs_offset_limit(gl_info))
......@@ -2813,8 +2784,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
checkGLcall("extension detection");
LEAVE_GL();
adapter->fragment_pipe = select_fragment_implementation(gl_info);
adapter->shader_backend = select_shader_backend(gl_info);
adapter->blitter = select_blit_implementation(gl_info);
......
......@@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
#include <stdio.h>
#include <math.h>
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static void drawStridedFast(const struct wined3d_gl_info *gl_info, GLenum primitive_type, UINT count, UINT idx_size,
const void *idx_data, UINT start_idx, INT base_vertex_index, UINT start_instance, UINT instance_count)
{
......@@ -81,7 +81,7 @@ static void drawStridedFast(const struct wined3d_gl_info *gl_info, GLenum primit
* Slower GL version which extracts info about each vertex in turn
*/
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static void drawStridedSlow(const struct wined3d_device *device, const struct wined3d_context *context,
const struct wined3d_stream_info *si, UINT NumVertexes, GLenum glPrimType,
const void *idxData, UINT idxSize, UINT startIdx)
......@@ -325,7 +325,7 @@ static void drawStridedSlow(const struct wined3d_device *device, const struct wi
checkGLcall("glEnd and previous calls");
}
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static inline void send_attribute(const struct wined3d_gl_info *gl_info,
enum wined3d_format_id format, const UINT index, const void *ptr)
{
......@@ -435,7 +435,7 @@ static inline void send_attribute(const struct wined3d_gl_info *gl_info,
}
}
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static void drawStridedSlowVs(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
const struct wined3d_stream_info *si, UINT numberOfVertices, GLenum glPrimitiveType,
const void *idxData, UINT idxSize, UINT startIdx)
......@@ -491,7 +491,7 @@ static void drawStridedSlowVs(const struct wined3d_gl_info *gl_info, const struc
gl_info->gl_ops.gl.p_glEnd();
}
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static void drawStridedInstanced(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
const struct wined3d_stream_info *si, UINT numberOfVertices, GLenum glPrimitiveType,
const void *idxData, UINT idxSize, UINT startIdx, UINT base_vertex_index, UINT instance_count)
......@@ -666,8 +666,6 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
FIXME("Point sprite coordinate origin switching not supported.\n");
}
/* Ok, we will be updating the screen from here onwards so grab the lock */
ENTER_GL();
{
GLenum glPrimType = state->gl_primitive_type;
INT base_vertex_index = state->base_vertex_index;
......@@ -769,9 +767,6 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
}
}
/* Finished updating the screen, restore lock */
LEAVE_GL();
if (ib_query)
wined3d_event_query_issue(ib_query, device);
for (i = 0; i < device->num_buffer_queries; ++i)
......@@ -895,8 +890,6 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct wined3d_rect_pat
patch->has_normals = TRUE;
patch->has_texcoords = FALSE;
ENTER_GL();
gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
checkGLcall("glMatrixMode(GL_PROJECTION)");
gl_info->gl_ops.gl.p_glLoadIdentity();
......@@ -1033,18 +1026,20 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct wined3d_rect_pat
i = gl_info->gl_ops.gl.p_glRenderMode(GL_RENDER);
if (i == -1)
{
LEAVE_GL();
ERR("Feedback failed. Expected %d elements back\n", buffer_size);
HeapFree(GetProcessHeap(), 0, feedbuffer);
context_release(context);
return WINED3DERR_DRIVERINTERNALERROR;
} else if(i != buffer_size) {
LEAVE_GL();
}
else if (i != buffer_size)
{
ERR("Unexpected amount of elements returned. Expected %d, got %d\n", buffer_size, i);
HeapFree(GetProcessHeap(), 0, feedbuffer);
context_release(context);
return WINED3DERR_DRIVERINTERNALERROR;
} else {
}
else
{
TRACE("Got %d elements as expected\n", i);
}
......@@ -1155,7 +1150,6 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct wined3d_rect_pat
gl_info->gl_ops.gl.p_glDisable(GL_MAP2_NORMAL);
gl_info->gl_ops.gl.p_glDisable(GL_MAP2_TEXTURE_COORD_4);
checkGLcall("glDisable vertex attrib generation");
LEAVE_GL();
context_release(context);
......
......@@ -29,7 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
/* GL locking for state handlers is done by the caller. */
/* Context activation for state handlers is done by the caller. */
static void nvts_activate_dimensions(const struct wined3d_state *state, DWORD stage, struct wined3d_context *context)
{
......@@ -652,7 +652,7 @@ static void nvrc_enable(const struct wined3d_gl_info *gl_info, BOOL enable)
}
}
/* Context activation and GL locking are done by the caller. */
/* Context activation is done by the caller. */
static void nvts_enable(const struct wined3d_gl_info *gl_info, BOOL enable)
{
nvrc_enable(gl_info, enable);
......
......@@ -61,8 +61,6 @@ static enum wined3d_event_query_result wined3d_event_query_test(const struct win
context = context_acquire(device, query->context->current_rt);
gl_info = context->gl_info;
ENTER_GL();
if (gl_info->supported[ARB_SYNC])
{
GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0));
......@@ -105,8 +103,6 @@ static enum wined3d_event_query_result wined3d_event_query_test(const struct win
ret = WINED3D_EVENT_QUERY_ERROR;
}
LEAVE_GL();
context_release(context);
return ret;
}
......@@ -138,7 +134,6 @@ enum wined3d_event_query_result wined3d_event_query_finish(const struct wined3d_
context = context_acquire(device, query->context->current_rt);
ENTER_GL();
if (gl_info->supported[ARB_SYNC])
{
/* Apple seems to be into arbitrary limits, and timeouts larger than
......@@ -177,7 +172,6 @@ enum wined3d_event_query_result wined3d_event_query_finish(const struct wined3d_
ERR("Event query created without GL support\n");
ret = WINED3D_EVENT_QUERY_ERROR;
}
LEAVE_GL();
context_release(context);
return ret;
......@@ -209,8 +203,6 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, const struct w
gl_info = context->gl_info;
ENTER_GL();
if (gl_info->supported[ARB_SYNC])
{
if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
......@@ -229,8 +221,6 @@ void wined3d_event_query_issue(struct wined3d_event_query *query, const struct w
checkGLcall("glSetFenceNV");
}
LEAVE_GL();
context_release(context);
}
......@@ -345,8 +335,6 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glGetQueryObjectuivARB(oq->id, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)");
TRACE("available %#x.\n", available);
......@@ -367,8 +355,6 @@ static HRESULT wined3d_occlusion_query_ops_get_data(struct wined3d_query *query,
res = S_FALSE;
}
LEAVE_GL();
context_release(context);
return res;
......@@ -480,10 +466,8 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
{
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
LEAVE_GL();
}
}
else
......@@ -493,10 +477,8 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
context_alloc_occlusion_query(context, oq);
}
ENTER_GL();
GL_EXTCALL(glBeginQueryARB(GL_SAMPLES_PASSED_ARB, oq->id));
checkGLcall("glBeginQuery()");
LEAVE_GL();
context_release(context);
}
......@@ -516,10 +498,8 @@ static HRESULT wined3d_occlusion_query_ops_issue(struct wined3d_query *query, DW
{
context = context_acquire(query->device, oq->context->current_rt);
ENTER_GL();
GL_EXTCALL(glEndQueryARB(GL_SAMPLES_PASSED_ARB));
checkGLcall("glEndQuery()");
LEAVE_GL();
context_release(context);
}
......
......@@ -38,7 +38,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
/* GL locking for state handlers is done by the caller. */
/* Context activation for state handler is done by the caller. */
static void state_undefined(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
......@@ -5657,7 +5657,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
};
/* Context activation and GL locking are done by the caller. */
/* Context activation is done by the caller. */
static void ffp_enable(const struct wined3d_gl_info *gl_info, BOOL enable) {}
static void ffp_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
......
......@@ -316,7 +316,6 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
surface_load_location(backbuffer, location, NULL);
}
ENTER_GL();
context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, backbuffer, NULL, location);
gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0);
context_check_fbo_status(context, GL_READ_FRAMEBUFFER);
......@@ -339,7 +338,6 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
dst_rect->left, win_h - dst_rect->top, dst_rect->right, win_h - dst_rect->bottom,
GL_COLOR_BUFFER_BIT, gl_filter);
checkGLcall("Swapchain present blit(EXT_framebuffer_blit)\n");
LEAVE_GL();
}
else
{
......@@ -364,7 +362,6 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
if (is_complex_fixup(backbuffer->resource.format->color_fixup))
gl_filter = GL_NEAREST;
ENTER_GL();
context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, swapchain->front_buffer, NULL, SFLAG_INDRAWABLE);
context_bind_texture(context2, backbuffer->texture_target, backbuffer->texture_name);
......@@ -414,7 +411,6 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
device->blitter->unset_shader(context->gl_info);
checkGLcall("Swapchain present blit(manual)\n");
LEAVE_GL();
context_release(context2);
}
......
......@@ -77,9 +77,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
/* A GL context is provided by the caller */
static void gltexture_delete(const struct wined3d_gl_info *gl_info, struct gl_texture *tex)
{
ENTER_GL();
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex->name);
LEAVE_GL();
tex->name = 0;
}
......@@ -153,7 +151,6 @@ static HRESULT wined3d_texture_bind(struct wined3d_texture *texture,
gl_tex = wined3d_texture_get_gl_texture(texture, context->gl_info, srgb);
target = texture->target;
ENTER_GL();
/* Generate a texture name if we don't already have one. */
if (!gl_tex->name)
{
......@@ -233,11 +230,10 @@ static HRESULT wined3d_texture_bind(struct wined3d_texture *texture,
hr = WINED3DERR_INVALIDCALL;
}
LEAVE_GL();
return hr;
}
/* GL locking is done by the caller */
/* Context activation is done by the caller. */
static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target,
enum wined3d_texture_address d3d_wrap, GLenum param, BOOL cond_np2)
{
......@@ -261,7 +257,7 @@ static void apply_wrap(const struct wined3d_gl_info *gl_info, GLenum target,
checkGLcall("glTexParameteri(target, param, gl_wrap)");
}
/* GL locking is done by the caller (state handler) */
/* Context activation is done by the caller (state handler). */
void wined3d_texture_apply_state_changes(struct wined3d_texture *texture,
const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1],
const struct wined3d_gl_info *gl_info)
......@@ -628,7 +624,6 @@ static HRESULT texture2d_bind(struct wined3d_texture *texture,
{
GLenum target = texture->target;
ENTER_GL();
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
checkGLcall("glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......@@ -637,7 +632,6 @@ static HRESULT texture2d_bind(struct wined3d_texture *texture,
checkGLcall("glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
checkGLcall("glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
LEAVE_GL();
gl_tex->states[WINED3DTEXSTA_ADDRESSU] = WINED3D_TADDRESS_CLAMP;
gl_tex->states[WINED3DTEXSTA_ADDRESSV] = WINED3D_TADDRESS_CLAMP;
gl_tex->states[WINED3DTEXSTA_MAGFILTER] = WINED3D_TEXF_POINT;
......
......@@ -991,8 +991,6 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
GLenum status;
GLuint tex;
ENTER_GL();
while (gl_info->gl_ops.gl.p_glGetError());
gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
......@@ -1194,8 +1192,6 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct wined
format->flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB;
gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
LEAVE_GL();
}
/* Context activation is done by the caller. */
......@@ -1206,14 +1202,10 @@ static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
ENTER_GL();
gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
gl_info->gl_ops.gl.p_glDrawBuffer(GL_COLOR_ATTACHMENT0);
gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0);
LEAVE_GL();
}
for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
......@@ -1248,13 +1240,7 @@ static void init_format_fbo_compat_info(struct wined3d_gl_info *gl_info)
}
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
ENTER_GL();
gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
LEAVE_GL();
}
}
static BOOL init_format_texture_info(struct wined3d_gl_info *gl_info)
......@@ -1345,7 +1331,6 @@ static BOOL check_filter(const struct wined3d_gl_info *gl_info, GLenum internal)
* than Wine. The Linux binary <= r500 driver is not maintained any more anyway
*/
ENTER_GL();
while (gl_info->gl_ops.gl.p_glGetError());
gl_info->gl_ops.gl.p_glGenTextures(1, &buffer);
......@@ -1423,7 +1408,7 @@ static BOOL check_filter(const struct wined3d_gl_info *gl_info, GLenum internal)
FIXME("Error during filtering test for format %x, returning no filtering\n", internal);
ret = FALSE;
}
LEAVE_GL();
return ret;
}
......@@ -2524,8 +2509,8 @@ BOOL is_invalid_op(const struct wined3d_state *state, int stage,
return FALSE;
}
/* Setup this textures matrix according to the texture flags*/
/* GL locking is done by the caller (state handler) */
/* Setup this textures matrix according to the texture flags. */
/* Context activation is done by the caller (state handler). */
void set_texture_matrix(const struct wined3d_gl_info *gl_info, const float *smat, DWORD flags,
BOOL calculatedCoords, BOOL transformed, enum wined3d_format_id vtx_fmt, BOOL ffp_proj_control)
{
......@@ -3174,11 +3159,10 @@ void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *des
}
}
/* Activates the texture dimension according to the bound D3D texture.
* Does not care for the colorop or correct gl texture unit(when using nvrc)
* Requires the caller to activate the correct unit before
*/
/* GL locking is done by the caller (state handler) */
/* Activates the texture dimension according to the bound D3D texture. Does
* not care for the colorop or correct gl texture unit (when using nvrc).
* Requires the caller to activate the correct unit. */
/* Context activation is done by the caller (state handler). */
void texture_activate_dimensions(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
{
if (texture)
......@@ -3265,7 +3249,7 @@ void texture_activate_dimensions(const struct wined3d_texture *texture, const st
}
}
/* GL locking is done by the caller (state handler) */
/* Context activation is done by the caller (state handler). */
void sampler_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
{
DWORD sampler = state_id - STATE_SAMPLER(0);
......
......@@ -88,12 +88,10 @@ void volume_load(const struct wined3d_volume *volume, struct wined3d_context *co
volume_bind_and_dirtify(volume, context);
ENTER_GL();
GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, level, format->glInternal,
volume->resource.width, volume->resource.height, volume->resource.depth,
0, format->glFormat, format->glType, volume->resource.allocatedMemory));
checkGLcall("glTexImage3D");
LEAVE_GL();
/* When adding code releasing volume->resource.allocatedMemory to save
* data keep in mind that GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by
......
......@@ -822,15 +822,6 @@ extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDD
extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
#define ENTER_GL() do {} while(0)
#define LEAVE_GL() do {} while(0)
/*****************************************************************************
* Defines
*/
/* GL related defines */
/* ------------------ */
#define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
......
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