wined3d: Introduce a separate structure for OpenGL rendertarget view information.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
366d2bb75e
commit
0799c3babd
|
@ -3053,10 +3053,11 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
|
|||
{
|
||||
if (rts[i])
|
||||
{
|
||||
context->blit_targets[i].gl_view = rts[i]->gl_view;
|
||||
context->blit_targets[i].resource = rts[i]->resource;
|
||||
context->blit_targets[i].sub_resource_idx = rts[i]->sub_resource_idx;
|
||||
context->blit_targets[i].layer_count = rts[i]->layer_count;
|
||||
struct wined3d_rendertarget_view_gl *rtv_gl = wined3d_rendertarget_view_gl(rts[i]);
|
||||
context->blit_targets[i].gl_view = rtv_gl->gl_view;
|
||||
context->blit_targets[i].resource = rtv_gl->v.resource;
|
||||
context->blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx;
|
||||
context->blit_targets[i].layer_count = rtv_gl->v.layer_count;
|
||||
}
|
||||
if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL)
|
||||
rt_mask |= (1u << i);
|
||||
|
@ -3064,10 +3065,11 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
|
|||
|
||||
if (dsv)
|
||||
{
|
||||
ds_info.gl_view = dsv->gl_view;
|
||||
ds_info.resource = dsv->resource;
|
||||
ds_info.sub_resource_idx = dsv->sub_resource_idx;
|
||||
ds_info.layer_count = dsv->layer_count;
|
||||
struct wined3d_rendertarget_view_gl *dsv_gl = wined3d_rendertarget_view_gl(dsv);
|
||||
ds_info.gl_view = dsv_gl->gl_view;
|
||||
ds_info.resource = dsv_gl->v.resource;
|
||||
ds_info.sub_resource_idx = dsv_gl->v.sub_resource_idx;
|
||||
ds_info.layer_count = dsv_gl->v.layer_count;
|
||||
}
|
||||
|
||||
context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, &ds_info,
|
||||
|
@ -3189,6 +3191,7 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat
|
|||
}
|
||||
else
|
||||
{
|
||||
const struct wined3d_rendertarget_view_gl *view_gl;
|
||||
unsigned int i;
|
||||
|
||||
memset(context->blit_targets, 0, sizeof(context->blit_targets));
|
||||
|
@ -3197,21 +3200,23 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat
|
|||
if (!fb->render_targets[i])
|
||||
continue;
|
||||
|
||||
context->blit_targets[i].gl_view = fb->render_targets[i]->gl_view;
|
||||
context->blit_targets[i].resource = fb->render_targets[i]->resource;
|
||||
context->blit_targets[i].sub_resource_idx = fb->render_targets[i]->sub_resource_idx;
|
||||
context->blit_targets[i].layer_count = fb->render_targets[i]->layer_count;
|
||||
view_gl = wined3d_rendertarget_view_gl(fb->render_targets[i]);
|
||||
context->blit_targets[i].gl_view = view_gl->gl_view;
|
||||
context->blit_targets[i].resource = view_gl->v.resource;
|
||||
context->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx;
|
||||
context->blit_targets[i].layer_count = view_gl->v.layer_count;
|
||||
|
||||
if (!color_location)
|
||||
color_location = fb->render_targets[i]->resource->draw_binding;
|
||||
color_location = view_gl->v.resource->draw_binding;
|
||||
}
|
||||
|
||||
if (fb->depth_stencil)
|
||||
{
|
||||
ds_info.gl_view = fb->depth_stencil->gl_view;
|
||||
ds_info.resource = fb->depth_stencil->resource;
|
||||
ds_info.sub_resource_idx = fb->depth_stencil->sub_resource_idx;
|
||||
ds_info.layer_count = fb->depth_stencil->layer_count;
|
||||
view_gl = wined3d_rendertarget_view_gl(fb->depth_stencil);
|
||||
ds_info.gl_view = view_gl->gl_view;
|
||||
ds_info.resource = view_gl->v.resource;
|
||||
ds_info.sub_resource_idx = view_gl->v.sub_resource_idx;
|
||||
ds_info.layer_count = view_gl->v.layer_count;
|
||||
}
|
||||
|
||||
context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, &ds_info,
|
||||
|
|
|
@ -342,25 +342,25 @@ ULONG CDECL wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *v
|
|||
return refcount;
|
||||
}
|
||||
|
||||
static void wined3d_rendertarget_view_destroy_object(void *object)
|
||||
static void wined3d_rendertarget_view_gl_destroy_object(void *object)
|
||||
{
|
||||
struct wined3d_rendertarget_view *view = object;
|
||||
struct wined3d_device *device = view->resource->device;
|
||||
struct wined3d_rendertarget_view_gl *view_gl = object;
|
||||
struct wined3d_device *device = view_gl->v.resource->device;
|
||||
|
||||
if (view->gl_view.name)
|
||||
if (view_gl->gl_view.name)
|
||||
{
|
||||
const struct wined3d_gl_info *gl_info;
|
||||
struct wined3d_context *context;
|
||||
|
||||
context = context_acquire(device, NULL, 0);
|
||||
gl_info = context->gl_info;
|
||||
context_gl_resource_released(device, view->gl_view.name, FALSE);
|
||||
gl_info->gl_ops.gl.p_glDeleteTextures(1, &view->gl_view.name);
|
||||
context_gl_resource_released(device, view_gl->gl_view.name, FALSE);
|
||||
gl_info->gl_ops.gl.p_glDeleteTextures(1, &view_gl->gl_view.name);
|
||||
checkGLcall("glDeleteTextures");
|
||||
context_release(context);
|
||||
}
|
||||
|
||||
heap_free(view);
|
||||
heap_free(view_gl);
|
||||
}
|
||||
|
||||
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
|
||||
|
@ -377,7 +377,8 @@ ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *v
|
|||
/* Call wined3d_object_destroyed() before releasing the resource,
|
||||
* since releasing the resource may end up destroying the parent. */
|
||||
view->parent_ops->wined3d_object_destroyed(view->parent);
|
||||
wined3d_cs_destroy_object(device->cs, wined3d_rendertarget_view_destroy_object, view);
|
||||
wined3d_cs_destroy_object(device->cs, wined3d_rendertarget_view_gl_destroy_object,
|
||||
wined3d_rendertarget_view_gl(view));
|
||||
wined3d_resource_decref(resource);
|
||||
}
|
||||
|
||||
|
@ -525,11 +526,11 @@ void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_v
|
|||
wined3d_view_invalidate_location(view->resource, &view->desc, location);
|
||||
}
|
||||
|
||||
static void wined3d_render_target_view_cs_init(void *object)
|
||||
static void wined3d_render_target_view_gl_cs_init(void *object)
|
||||
{
|
||||
struct wined3d_rendertarget_view *view = object;
|
||||
struct wined3d_resource *resource = view->resource;
|
||||
const struct wined3d_view_desc *desc = &view->desc;
|
||||
struct wined3d_rendertarget_view_gl *view_gl = object;
|
||||
struct wined3d_resource *resource = view_gl->v.resource;
|
||||
const struct wined3d_view_desc *desc = &view_gl->v.desc;
|
||||
|
||||
if (resource->type == WINED3D_RTYPE_BUFFER)
|
||||
{
|
||||
|
@ -545,17 +546,17 @@ static void wined3d_render_target_view_cs_init(void *object)
|
|||
else
|
||||
depth_or_layer_count = texture_gl->t.layer_count;
|
||||
|
||||
if (resource->format->id != view->format->id
|
||||
|| (view->layer_count != 1 && view->layer_count != depth_or_layer_count))
|
||||
if (resource->format->id != view_gl->v.format->id
|
||||
|| (view_gl->v.layer_count != 1 && view_gl->v.layer_count != depth_or_layer_count))
|
||||
{
|
||||
GLenum resource_class, view_class;
|
||||
|
||||
resource_class = wined3d_format_gl(resource->format)->view_class;
|
||||
view_class = wined3d_format_gl(view->format)->view_class;
|
||||
view_class = wined3d_format_gl(view_gl->v.format)->view_class;
|
||||
if (resource_class != view_class)
|
||||
{
|
||||
FIXME("Render target view not supported, resource format %s, view format %s.\n",
|
||||
debug_d3dformat(resource->format->id), debug_d3dformat(view->format->id));
|
||||
debug_d3dformat(resource->format->id), debug_d3dformat(view_gl->v.format->id));
|
||||
return;
|
||||
}
|
||||
if (texture_gl->t.swapchain && texture_gl->t.swapchain->desc.backbuffer_count > 1)
|
||||
|
@ -564,7 +565,7 @@ static void wined3d_render_target_view_cs_init(void *object)
|
|||
return;
|
||||
}
|
||||
|
||||
create_texture_view(&view->gl_view, texture_gl->target, desc, texture_gl, view->format);
|
||||
create_texture_view(&view_gl->gl_view, texture_gl->target, desc, texture_gl, view_gl->v.format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -612,8 +613,6 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
|
|||
|
||||
wined3d_resource_incref(view->resource = resource);
|
||||
|
||||
wined3d_cs_init_object(resource->device->cs, wined3d_render_target_view_cs_init, view);
|
||||
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
|
@ -621,7 +620,7 @@ HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *d
|
|||
struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
|
||||
struct wined3d_rendertarget_view **view)
|
||||
{
|
||||
struct wined3d_rendertarget_view *object;
|
||||
struct wined3d_rendertarget_view_gl *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
|
||||
|
@ -630,15 +629,17 @@ HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *d
|
|||
if (!(object = heap_alloc_zero(sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = wined3d_rendertarget_view_init(object, desc, resource, parent, parent_ops)))
|
||||
if (FAILED(hr = wined3d_rendertarget_view_init(&object->v, desc, resource, parent, parent_ops)))
|
||||
{
|
||||
heap_free(object);
|
||||
WARN("Failed to initialise view, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
wined3d_cs_init_object(resource->device->cs, wined3d_render_target_view_gl_cs_init, object);
|
||||
|
||||
TRACE("Created render target view %p.\n", object);
|
||||
*view = object;
|
||||
*view = &object->v;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -3830,7 +3830,6 @@ struct wined3d_rendertarget_view
|
|||
void *parent;
|
||||
const struct wined3d_parent_ops *parent_ops;
|
||||
|
||||
struct wined3d_gl_view gl_view;
|
||||
const struct wined3d_format *format;
|
||||
unsigned int format_flags;
|
||||
unsigned int sub_resource_idx;
|
||||
|
@ -3853,6 +3852,18 @@ void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
|
|||
void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
|
||||
DWORD location) DECLSPEC_HIDDEN;
|
||||
|
||||
struct wined3d_rendertarget_view_gl
|
||||
{
|
||||
struct wined3d_rendertarget_view v;
|
||||
struct wined3d_gl_view gl_view;
|
||||
};
|
||||
|
||||
static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
|
||||
struct wined3d_rendertarget_view *view)
|
||||
{
|
||||
return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
|
||||
}
|
||||
|
||||
struct wined3d_shader_resource_view
|
||||
{
|
||||
LONG refcount;
|
||||
|
|
Loading…
Reference in New Issue