/* Context activation is done by the caller. */ static void wined3d_volume_download_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_bo_address *data) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; if (format->convert) { FIXME("Attempting to download a converted volume, format %s.\n", debug_d3dformat(format->id)); return; } if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, data->buffer_object)); checkGLcall("glBindBufferARB"); } gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_3D, volume->texture_level, format->glFormat, format->glType, data->addr); checkGLcall("glGetTexImage"); if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)); checkGLcall("glBindBufferARB"); } }
/* Context activation is done by the caller. */ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_bo_address *data) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; TRACE("volume %p, context %p, level %u, format %s (%#x).\n", volume, context, volume->texture_level, debug_d3dformat(format->id), format->id); if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, data->buffer_object)); checkGLcall("glBindBufferARB"); } GL_EXTCALL(glTexSubImage3DEXT(GL_TEXTURE_3D, volume->texture_level, 0, 0, 0, volume->resource.width, volume->resource.height, volume->resource.depth, format->glFormat, format->glType, data->addr)); checkGLcall("glTexSubImage3D"); if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); checkGLcall("glBindBufferARB"); } }
void wined3d_resource_release_map_ptr(const struct wined3d_resource *resource, const struct wined3d_context *context) { const struct wined3d_gl_info *gl_info; switch (resource->map_binding) { case WINED3D_LOCATION_BUFFER: gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, resource->map_buffer->name)); GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER)); GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); checkGLcall("Unmap GL buffer"); return; case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_DIB: case WINED3D_LOCATION_USER_MEMORY: return; default: ERR("Unexpected map binding %s.\n", wined3d_debug_location(resource->map_binding)); return; } }
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) { TRACE("volume %p.\n", volume); if (!(volume->flags & WINED3D_VFLAG_LOCKED)) { WARN("Trying to unlock unlocked volume %p.\n", volume); return WINED3DERR_INVALIDCALL; } if (volume->flags & WINED3D_VFLAG_PBO) { struct wined3d_device *device = volume->resource.device; struct wined3d_context *context = context_acquire(device, NULL); const struct wined3d_gl_info *gl_info = context->gl_info; GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, volume->pbo)); GL_EXTCALL(glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); checkGLcall("Unmap PBO"); context_release(context); } volume->flags &= ~WINED3D_VFLAG_LOCKED; return WINED3D_OK; }
void swapchain_update_surface(struct wined3d_swapchain *swapchain) { const struct wined3d_gl_info *gl_info = &swapchain->device->adapter->gl_info; if (gl_info->supported[WGL_WINE_SURFACE]) { HDC hdc; if (swapchain->surface && !GL_EXTCALL(wglDestroySurfaceWINE(swapchain->surface))) ERR("wglDestroySurfaceWINE failed to destroy surface %p\n", swapchain->surface); if (swapchain->desc.windowed) hdc = GetDC(swapchain->win_handle); else hdc = CreateDCW(swapchain->device->adapter->DeviceName, swapchain->device->adapter->DeviceName, NULL, NULL); swapchain->surface = GL_EXTCALL(wglCreateSurfaceWINE(hdc, swapchain->win_handle)); if (!swapchain->surface) WARN("wglCreateSurfaceWINE failed to create surface for window %p\n", swapchain->desc.windowed ? swapchain->win_handle : NULL); if (swapchain->desc.windowed) ReleaseDC(swapchain->win_handle, hdc); else DeleteDC(hdc); } }
HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) { TRACE("volume %p.\n", volume); if (!volume->resource.map_count) { WARN("Trying to unlock an unlocked volume %p.\n", volume); return WINED3DERR_INVALIDCALL; } if (volume->resource.map_binding == WINED3D_LOCATION_BUFFER) { struct wined3d_device *device = volume->resource.device; struct wined3d_context *context = context_acquire(device, NULL); const struct wined3d_gl_info *gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, volume->pbo)); GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER)); GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); checkGLcall("Unmap PBO"); context_release(context); } volume->resource.map_count--; return WINED3D_OK; }
static HRESULT wined3d_timestamp_query_ops_get_data(struct wined3d_query *query, void *data, DWORD size, DWORD flags) { struct wined3d_timestamp_query *tq = query->extendedData; struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; GLuint available; GLuint64 timestamp; HRESULT res; TRACE("query %p, data %p, size %#x, flags %#x.\n", query, data, size, flags); if (!tq->context) query->state = QUERY_CREATED; if (query->state == QUERY_CREATED) { /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves. */ TRACE("Query wasn't yet started, returning S_OK.\n"); timestamp = 0; fill_query_data(data, size, ×tamp, sizeof(timestamp)); return S_OK; } if (tq->context->tid != GetCurrentThreadId()) { FIXME("%p Wrong thread, returning 1.\n", query); timestamp = 1; fill_query_data(data, size, ×tamp, sizeof(timestamp)); return S_OK; } context = context_acquire(query->device, tq->context->current_rt); GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available)); checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)"); TRACE("available %#x.\n", available); if (available) { if (size) { GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT, ×tamp)); checkGLcall("glGetQueryObjectui64v(GL_QUERY_RESULT)"); TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp)); fill_query_data(data, size, ×tamp, sizeof(timestamp)); } res = S_OK; } else { res = S_FALSE; } context_release(context); return res; }
/* Context activation is done by the caller. */ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_const_bo_address *data) { const struct wined3d_gl_info *gl_info = context->gl_info; struct wined3d_texture *texture = volume->container; const struct wined3d_format *format = texture->resource.format; unsigned int width, height, depth; const void *mem = data->addr; void *converted_mem = NULL; TRACE("volume %p, context %p, level %u, format %s (%#x).\n", volume, context, volume->texture_level, debug_d3dformat(format->id), format->id); width = wined3d_texture_get_level_width(texture, volume->texture_level); height = wined3d_texture_get_level_height(texture, volume->texture_level); depth = wined3d_texture_get_level_depth(texture, volume->texture_level); if (format->convert) { UINT dst_row_pitch, dst_slice_pitch; UINT src_row_pitch, src_slice_pitch; if (data->buffer_object) ERR("Loading a converted volume from a PBO.\n"); if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS) ERR("Converting a block-based format.\n"); dst_row_pitch = width * format->conv_byte_count; dst_slice_pitch = dst_row_pitch * height; wined3d_texture_get_pitch(texture, volume->texture_level, &src_row_pitch, &src_slice_pitch); converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth); format->convert(data->addr, converted_mem, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, width, height, depth); mem = converted_mem; } if (data->buffer_object) { GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object)); checkGLcall("glBindBuffer"); } GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, volume->texture_level, 0, 0, 0, width, height, depth, format->glFormat, format->glType, mem)); checkGLcall("glTexSubImage3D"); if (data->buffer_object) { GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); checkGLcall("glBindBuffer"); } HeapFree(GetProcessHeap(), 0, converted_mem); }
/* Context activation is done by the caller. */ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_bo_address *data) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; UINT width = volume->resource.width; UINT height = volume->resource.height; UINT depth = volume->resource.depth; BYTE *mem = data->addr; TRACE("volume %p, context %p, level %u, format %s (%#x).\n", volume, context, volume->texture_level, debug_d3dformat(format->id), format->id); if (format->convert) { UINT dst_row_pitch, dst_slice_pitch; UINT src_row_pitch, src_slice_pitch; UINT alignment = volume->resource.device->surface_alignment; if (data->buffer_object) ERR("Loading a converted volume from a PBO.\n"); if (format->flags & WINED3DFMT_FLAG_BLOCKS) ERR("Converting a block-based format.\n"); dst_row_pitch = width * format->conv_byte_count; dst_row_pitch = (dst_row_pitch + alignment - 1) & ~(alignment - 1); dst_slice_pitch = dst_row_pitch * height; wined3d_volume_get_pitch(volume, &src_row_pitch, &src_slice_pitch); mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth); format->convert(data->addr, mem, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, width, height, depth); } if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, data->buffer_object)); checkGLcall("glBindBufferARB"); } GL_EXTCALL(glTexSubImage3DEXT(GL_TEXTURE_3D, volume->texture_level, 0, 0, 0, width, height, depth, format->glFormat, format->glType, mem)); checkGLcall("glTexSubImage3D"); if (data->buffer_object) { GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); checkGLcall("glBindBufferARB"); } if (mem != data->addr) HeapFree(GetProcessHeap(), 0, mem); }
void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if (query->context) { if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) { #ifdef VBOX_WINE_WITH_SINGLE_CONTEXT ERR("unexpected\n"); #endif context_free_event_query(query); context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); context_alloc_event_query(context, query); } else { context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD); } } else { context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); context_alloc_event_query(context, query); } gl_info = context->gl_info; ENTER_GL(); if (gl_info->supported[ARB_SYNC]) { if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync)); checkGLcall("glDeleteSync"); query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); checkGLcall("glFenceSync"); } else if (gl_info->supported[APPLE_FENCE]) { GL_EXTCALL(glSetFenceAPPLE(query->object.id)); checkGLcall("glSetFenceAPPLE"); } else if (gl_info->supported[NV_FENCE]) { GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV)); checkGLcall("glSetFenceNV"); } LEAVE_GL(); context_release(context); }
/* Context activation is done by the caller. */ static void wined3d_volume_prepare_pbo(struct wined3d_volume *volume, struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; if (volume->pbo) return; GL_EXTCALL(glGenBuffersARB(1, &volume->pbo)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, volume->pbo)); GL_EXTCALL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, volume->resource.size, NULL, GL_STREAM_DRAW_ARB)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); checkGLcall("Create PBO"); TRACE("Created PBO %u for volume %p.\n", volume->pbo, volume); }
/* Context activation is done by the caller. */ static void wined3d_volume_allocate_texture(struct wined3d_volume *volume, const struct wined3d_context *context, BOOL srgb) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; void *mem = NULL; if (gl_info->supported[APPLE_CLIENT_STORAGE] && !format->convert && volume_prepare_system_memory(volume)) { TRACE("Enabling GL_UNPACK_CLIENT_STORAGE_APPLE for volume %p\n", volume); gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)"); mem = volume->resource.heap_memory; volume->flags |= WINED3D_VFLAG_CLIENT_STORAGE; } GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, volume->texture_level, srgb ? format->glGammaInternal : format->glInternal, volume->resource.width, volume->resource.height, volume->resource.depth, 0, format->glFormat, format->glType, mem)); checkGLcall("glTexImage3D"); if (mem) { gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)"); } }
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view, unsigned int value) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if (!view->counter_bo) return; context = context_acquire(view->resource->device, NULL, 0); gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo)); GL_EXTCALL(glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(value), &value)); checkGLcall("set atomic counter"); context_release(context); }
/* Context activation is done by the caller. */ static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) { IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; const struct wined3d_gl_info *gl_info = &This->resource.device->adapter->gl_info; const struct wined3d_format *format = This->resource.format; TRACE("iface %p, level %u, srgb %#x, format %s (%#x).\n", iface, gl_level, srgb_mode, debug_d3dformat(format->id), format->id); volume_bind_and_dirtify(iface); TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n", GL_TEXTURE_3D, gl_level, format->glInternal, This->currentDesc.Width, This->currentDesc.Height, This->currentDesc.Depth, 0, format->glFormat, format->glType, This->resource.allocatedMemory); ENTER_GL(); GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, gl_level, format->glInternal, This->currentDesc.Width, This->currentDesc.Height, This->currentDesc.Depth, 0, format->glFormat, format->glType, This->resource.allocatedMemory)); checkGLcall("glTexImage3D"); LEAVE_GL(); /* When adding code releasing This->resource.allocatedMemory to save data keep in mind that * GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by default if supported(GL_APPLE_client_storage). * Thus do not release This->resource.allocatedMemory if GL_APPLE_client_storage is supported. */ return WINED3D_OK; }
static void wined3d_shader_resource_view_create_texture_view(struct wined3d_shader_resource_view *view, const struct wined3d_shader_resource_view_desc *desc, struct wined3d_texture *texture, const struct wined3d_format *view_format) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context; struct gl_texture *gl_texture; context = context_acquire(texture->resource.device, NULL); gl_info = context->gl_info; if (!gl_info->supported[ARB_TEXTURE_VIEW]) { context_release(context); FIXME("OpenGL implementation does not support texture views.\n"); return; } wined3d_texture_prepare_texture(texture, context, FALSE); gl_texture = wined3d_texture_get_gl_texture(texture, FALSE); gl_info->gl_ops.gl.p_glGenTextures(1, &view->object); GL_EXTCALL(glTextureView(view->object, view->target, gl_texture->name, view_format->glInternal, desc->u.texture.level_idx, desc->u.texture.level_count, desc->u.texture.layer_idx, desc->u.texture.layer_count)); checkGLcall("Create texture view"); context_release(context); }
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_level) { IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; const PixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format); if(GL_SUPPORT(EXT_TEXTURE3D)) { TRACE("Calling glTexImage3D %x level=%d, intfmt=%x, w=%d, h=%d,d=%d, 0=%d, glFmt=%x, glType=%x, Mem=%p\n", GL_TEXTURE_3D, gl_level, formatEntry->glInternal, This->currentDesc.Width, This->currentDesc.Height, This->currentDesc.Depth, 0, formatEntry->glFormat, formatEntry->glType, This->resource.allocatedMemory); GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, gl_level, formatEntry->glInternal, This->currentDesc.Width, This->currentDesc.Height, This->currentDesc.Depth, 0, formatEntry->glFormat, formatEntry->glType, This->resource.allocatedMemory)); checkGLcall("glTexImage3D"); } else WARN("This OpenGL implementation doesn't support 3D textures\n"); return WINED3D_OK; }
static BOOL wined3d_timestamp_query_ops_poll(struct wined3d_query *query) { struct wined3d_timestamp_query *tq = query->extendedData; struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; GLuint available; GLuint64 timestamp; BOOL ret; if (!gl_info->supported[ARB_TIMER_QUERY]) { TRACE("Faking timestamp.\n"); QueryPerformanceCounter((LARGE_INTEGER *)&tq->timestamp); return TRUE; } if (tq->context->tid != GetCurrentThreadId()) { FIXME("%p Wrong thread, returning 1.\n", query); tq->timestamp = 1; return TRUE; } context = context_acquire(device, context_get_rt_surface(tq->context)); GL_EXTCALL(glGetQueryObjectuiv(tq->id, GL_QUERY_RESULT_AVAILABLE, &available)); checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)"); TRACE("available %#x.\n", available); if (available) { GL_EXTCALL(glGetQueryObjectui64v(tq->id, GL_QUERY_RESULT, ×tamp)); checkGLcall("glGetQueryObjectui64v(GL_QUERY_RESULT)"); TRACE("Returning timestamp %s.\n", wine_dbgstr_longlong(timestamp)); tq->timestamp = timestamp; ret = TRUE; } else { ret = FALSE; } context_release(context); return ret; }
static void wined3d_unordered_access_view_cs_init(void *object) { struct wined3d_unordered_access_view *view = object; struct wined3d_resource *resource = view->resource; struct wined3d_view_desc *desc = &view->desc; const struct wined3d_gl_info *gl_info; gl_info = &resource->device->adapter->gl_info; if (resource->type == WINED3D_RTYPE_BUFFER) { struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_context *context; context = context_acquire(resource->device, NULL, 0); gl_info = context->gl_info; create_buffer_view(&view->gl_view, context, desc, buffer, view->format); if (desc->flags & (WINED3D_VIEW_BUFFER_COUNTER | WINED3D_VIEW_BUFFER_APPEND)) { static const GLuint initial_value = 0; GL_EXTCALL(glGenBuffers(1, &view->counter_bo)); GL_EXTCALL(glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, view->counter_bo)); GL_EXTCALL(glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(initial_value), &initial_value, GL_STATIC_DRAW)); checkGLcall("create atomic counter buffer"); } context_release(context); } else { struct wined3d_texture *texture = texture_from_resource(resource); unsigned int depth_or_layer_count; if (resource->type == WINED3D_RTYPE_TEXTURE_3D) depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx); else depth_or_layer_count = texture->layer_count; if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count) { create_texture_view(&view->gl_view, get_texture_view_target(gl_info, desc, texture), desc, texture, view->format); } } wined3d_resource_release(resource); }
void wined3d_event_query_issue(struct wined3d_event_query *query, const struct wined3d_device *device) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if (query->context) { if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) { context_free_event_query(query); context = context_acquire(device, NULL); context_alloc_event_query(context, query); } else { context = context_acquire(device, query->context->current_rt); } } else { context = context_acquire(device, NULL); context_alloc_event_query(context, query); } gl_info = context->gl_info; if (gl_info->supported[ARB_SYNC]) { if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync)); checkGLcall("glDeleteSync"); query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)); checkGLcall("glFenceSync"); } else if (gl_info->supported[APPLE_FENCE]) { GL_EXTCALL(glSetFenceAPPLE(query->object.id)); checkGLcall("glSetFenceAPPLE"); } else if (gl_info->supported[NV_FENCE]) { GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV)); checkGLcall("glSetFenceNV"); } context_release(context); }
void wined3d_sampler_destroy(struct wined3d_sampler *sampler) { struct wined3d_context *context = context_acquire(sampler->device, NULL); const struct wined3d_gl_info *gl_info = context->gl_info; GL_EXTCALL(glDeleteSamplers(1, &sampler->name)); context_release(context); HeapFree(GetProcessHeap(), 0, sampler); }
BYTE *wined3d_resource_get_map_ptr(const struct wined3d_resource *resource, const struct wined3d_context *context, DWORD flags) { const struct wined3d_gl_info *gl_info; BYTE *ptr; switch (resource->map_binding) { case WINED3D_LOCATION_BUFFER: gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, resource->map_buffer->name)); if (gl_info->supported[ARB_MAP_BUFFER_RANGE]) { GLbitfield mapflags = wined3d_resource_gl_map_flags(flags); mapflags &= ~GL_MAP_FLUSH_EXPLICIT_BIT; ptr = GL_EXTCALL(glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, resource->size, mapflags)); } else { GLenum access = wined3d_resource_gl_legacy_map_flags(flags); ptr = GL_EXTCALL(glMapBuffer(GL_PIXEL_UNPACK_BUFFER, access)); } GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); checkGLcall("Map GL buffer"); return ptr; case WINED3D_LOCATION_SYSMEM: return resource->map_heap_memory; case WINED3D_LOCATION_DIB: return resource->bitmap_data; case WINED3D_LOCATION_USER_MEMORY: return resource->user_memory; default: ERR("Unexpected map binding %s.\n", wined3d_debug_location(resource->map_binding)); return NULL; } }
static void wined3d_volume_free_pbo(struct wined3d_volume *volume) { struct wined3d_context *context = context_acquire(volume->resource.device, NULL); const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Deleting PBO %u belonging to volume %p.\n", volume->pbo, volume); GL_EXTCALL(glDeleteBuffersARB(1, &volume->pbo)); checkGLcall("glDeleteBuffersARB"); volume->pbo = 0; context_release(context); }
static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_context *context, struct wined3d_buffer *buffer, const struct wined3d_format *view_format, unsigned int offset, unsigned int size) { const struct wined3d_gl_info *gl_info = context->gl_info; if (!gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) { FIXME("OpenGL implementation does not support buffer textures.\n"); return; } if ((offset & (gl_info->limits.texture_buffer_offset_alignment - 1))) { FIXME("Buffer offset %u is not %u byte aligned.\n", offset, gl_info->limits.texture_buffer_offset_alignment); return; } wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER); view->target = GL_TEXTURE_BUFFER; gl_info->gl_ops.gl.p_glGenTextures(1, &view->name); context_bind_texture(context, GL_TEXTURE_BUFFER, view->name); if (gl_info->supported[ARB_TEXTURE_BUFFER_RANGE]) { GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object, offset, size)); } else { if (offset || size != buffer->resource.size) FIXME("OpenGL implementation does not support ARB_texture_buffer_range.\n"); GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format->glInternal, buffer->buffer_object)); } checkGLcall("Create buffer texture"); context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING); context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING); }
/* Context activation is done by the caller. */ static void wined3d_volume_allocate_texture(const struct wined3d_volume *volume, const struct wined3d_context *context, BOOL srgb) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, volume->texture_level, srgb ? format->glGammaInternal : format->glInternal, volume->resource.width, volume->resource.height, volume->resource.depth, 0, format->glFormat, format->glType, NULL)); checkGLcall("glTexImage3D"); }
static BOOL wined3d_occlusion_query_ops_poll(struct wined3d_query *query) { struct wined3d_occlusion_query *oq = query->extendedData; struct wined3d_device *device = query->device; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; GLuint available; GLuint samples; BOOL ret; if (oq->context->tid != GetCurrentThreadId()) { FIXME("%p Wrong thread, returning 1.\n", query); oq->samples = 1; return TRUE; } context = context_acquire(device, context_get_rt_surface(oq->context)); GL_EXTCALL(glGetQueryObjectuiv(oq->id, GL_QUERY_RESULT_AVAILABLE, &available)); checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT_AVAILABLE)"); TRACE("available %#x.\n", available); if (available) { GL_EXTCALL(glGetQueryObjectuiv(oq->id, GL_QUERY_RESULT, &samples)); checkGLcall("glGetQueryObjectuiv(GL_QUERY_RESULT)"); TRACE("Returning %d samples.\n", samples); oq->samples = samples; ret = TRUE; } else { ret = FALSE; } context_release(context); return ret; }
/* Context activation is optionally by the caller. Context may be NULL. */ static void wined3d_resource_copy_simple_location(struct wined3d_resource *resource, struct wined3d_context *context, DWORD location) { const struct wined3d_gl_info *gl_info; struct wined3d_bo_address dst, src; UINT size = resource->size; wined3d_resource_get_memory(resource, location, &dst); wined3d_resource_get_memory(resource, resource->locations, &src); if (dst.buffer_object) { gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, dst.buffer_object)); GL_EXTCALL(glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, size, src.addr)); GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0)); checkGLcall("Upload PBO"); return; } if (src.buffer_object) { gl_info = context->gl_info; GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, src.buffer_object)); GL_EXTCALL(glGetBufferSubData(GL_PIXEL_PACK_BUFFER, 0, size, dst.addr)); GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0)); checkGLcall("Download PBO"); return; } memcpy(dst.addr, src.addr, size); }
static void wined3d_sampler_destroy_object(void *object) { struct wined3d_sampler *sampler = object; const struct wined3d_gl_info *gl_info; struct wined3d_context *context; if (sampler->name) { context = context_acquire(sampler->device, NULL, 0); gl_info = context->gl_info; GL_EXTCALL(glDeleteSamplers(1, &sampler->name)); context_release(context); } heap_free(sampler); }
void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value, struct wined3d_context *context) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format; struct wined3d_resource *resource; struct wined3d_buffer *buffer; unsigned int offset, size; resource = view->resource; if (resource->type != WINED3D_RTYPE_BUFFER) { FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); return; } if (!gl_info->supported[ARB_CLEAR_BUFFER_OBJECT]) { FIXME("OpenGL implementation does not support ARB_clear_buffer_object.\n"); return; } format = view->format; if (format->id != WINED3DFMT_R32_UINT && format->id != WINED3DFMT_R32_SINT && format->id != WINED3DFMT_R32G32B32A32_UINT && format->id != WINED3DFMT_R32G32B32A32_SINT) { FIXME("Not implemented for format %s.\n", debug_d3dformat(format->id)); return; } buffer = buffer_from_resource(resource); wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER); wined3d_unordered_access_view_invalidate_location(view, ~WINED3D_LOCATION_BUFFER); get_buffer_view_range(buffer, &view->desc, format, &offset, &size); context_bind_bo(context, buffer->buffer_type_hint, buffer->buffer_object); GL_EXTCALL(glClearBufferSubData(buffer->buffer_type_hint, format->glInternal, offset, size, format->glFormat, format->glType, clear_value)); checkGLcall("clear unordered access view"); }
/* Context activation is done by the caller. */ void volume_load(const struct wined3d_volume *volume, struct wined3d_context *context, UINT level, BOOL srgb_mode) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_format *format = volume->resource.format; TRACE("volume %p, context %p, level %u, srgb %#x, format %s (%#x).\n", volume, context, level, srgb_mode, debug_d3dformat(format->id), format->id); volume_bind_and_dirtify(volume, context); 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"); /* When adding code releasing volume->resource.allocatedMemory to save * data keep in mind that GL_UNPACK_CLIENT_STORAGE_APPLE is enabled by * default if supported(GL_APPLE_client_storage). Thus do not release * volume->resource.allocatedMemory if GL_APPLE_client_storage is * supported. */ }
static void wined3d_unordered_access_view_destroy_object(void *object) { struct wined3d_unordered_access_view *view = object; if (view->gl_view.name || view->counter_bo) { const struct wined3d_gl_info *gl_info; struct wined3d_context *context; context = context_acquire(view->resource->device, NULL, 0); gl_info = context->gl_info; if (view->gl_view.name) gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->gl_view.name); if (view->counter_bo) GL_EXTCALL(glDeleteBuffers(1, &view->counter_bo)); checkGLcall("delete resources"); context_release(context); } heap_free(view); }