wined3d: Limit number of supported render targets to 8.

Virtually all relatively modern GPUs support 8 render targets.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-02-25 23:23:33 +01:00 committed by Alexandre Julliard
parent 7e2e472955
commit 1075b4615b
5 changed files with 19 additions and 42 deletions

View File

@ -3039,7 +3039,7 @@ static BOOL context_validate_rt_config(UINT rt_count, struct wined3d_rendertarge
BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
UINT rt_count, const struct wined3d_fb_state *fb)
{
struct wined3d_rendertarget_view **rts = fb->render_targets;
struct wined3d_rendertarget_view * const *rts = fb->render_targets;
struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD rt_mask = 0, *cur_mask;
@ -3148,7 +3148,7 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win
static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const struct wined3d_state *state)
{
struct wined3d_rendertarget_view **rts = state->fb->render_targets;
struct wined3d_rendertarget_view * const *rts = state->fb->render_targets;
struct wined3d_shader *ps = state->shader[WINED3D_SHADER_TYPE_PIXEL];
DWORD rt_mask, rt_mask_bits;
unsigned int i;

View File

@ -563,17 +563,11 @@ void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined
const RECT *rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
{
struct wined3d_cs_clear *op;
struct
{
struct wined3d_rendertarget_view *rt;
struct wined3d_fb_state fb;
} *extra;
size_t size;
op = cs->ops->require_space(cs, FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(*extra),
WINED3D_CS_QUEUE_DEFAULT);
extra = (void *)&op->rects[1];
extra->fb.render_targets = &extra->rt;
op->fb = &extra->fb;
size = FIELD_OFFSET(struct wined3d_cs_clear, rects[1]) + sizeof(struct wined3d_fb_state);
op = cs->ops->require_space(cs, size, WINED3D_CS_QUEUE_DEFAULT);
op->fb = (void *)&op->rects[1];
op->opcode = WINED3D_CS_OP_CLEAR;
op->flags = flags;
@ -994,7 +988,7 @@ static void wined3d_cs_exec_set_rendertarget_view(struct wined3d_cs *cs, const v
{
const struct wined3d_cs_set_rendertarget_view *op = data;
cs->state.fb->render_targets[op->view_idx] = op->view;
cs->fb.render_targets[op->view_idx] = op->view;
device_invalidate_state(cs->device, STATE_FRAMEBUFFER);
}
@ -2734,12 +2728,6 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
cs->ops = &wined3d_cs_st_ops;
cs->device = device;
if (!(cs->fb.render_targets = heap_calloc(gl_info->limits.buffers, sizeof(*cs->fb.render_targets))))
{
heap_free(cs);
return NULL;
}
state_init(&cs->state, &cs->fb, gl_info, &device->adapter->d3d_info,
WINED3D_STATE_NO_REF | WINED3D_STATE_INIT_DEFAULT);
@ -2782,7 +2770,6 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)
fail:
state_cleanup(&cs->state);
heap_free(cs->fb.render_targets);
heap_free(cs);
return NULL;
}
@ -2798,7 +2785,6 @@ void wined3d_cs_destroy(struct wined3d_cs *cs)
}
state_cleanup(&cs->state);
heap_free(cs->fb.render_targets);
heap_free(cs->data);
heap_free(cs);
}

View File

@ -1050,7 +1050,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
struct wined3d_swapchain_desc *swapchain_desc)
{
static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 0.0f};
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_swapchain *swapchain = NULL;
DWORD clear_flags = 0;
HRESULT hr;
@ -1062,16 +1061,14 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
if (device->wined3d->flags & WINED3D_NO3D)
return WINED3DERR_INVALIDCALL;
if (!(device->fb.render_targets = heap_calloc(gl_info->limits.buffers, sizeof(*device->fb.render_targets))))
return E_OUTOFMEMORY;
memset(device->fb.render_targets, 0, sizeof(device->fb.render_targets));
/* Setup the implicit swapchain. This also initializes a context. */
TRACE("Creating implicit swapchain\n");
hr = device->device_parent->ops->create_swapchain(device->device_parent,
swapchain_desc, &swapchain);
if (FAILED(hr))
TRACE("Creating implicit swapchain.\n");
if (FAILED(hr = device->device_parent->ops->create_swapchain(device->device_parent,
swapchain_desc, &swapchain)))
{
WARN("Failed to create implicit swapchain\n");
WARN("Failed to create implicit swapchain.\n");
goto err_out;
}
@ -1108,7 +1105,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
device->contexts[0]->last_was_rhw = 0;
TRACE("All defaults now set up, leaving 3D init.\n");
TRACE("All defaults now set up.\n");
/* Clear the screen */
if (swapchain->back_buffers && swapchain->back_buffers[0])
@ -1131,7 +1128,6 @@ err_out:
wined3d_rendertarget_view_decref(device->back_buffer_view);
if (swapchain)
wined3d_swapchain_decref(swapchain);
heap_free(device->fb.render_targets);
return hr;
}
@ -1186,7 +1182,7 @@ static void device_free_sampler(struct wine_rb_entry *entry, void *context)
HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
{
UINT i;
unsigned int i;
TRACE("device %p.\n", device);
@ -1246,9 +1242,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
device->swapchains = NULL;
device->swapchain_count = 0;
heap_free(device->fb.render_targets);
device->fb.render_targets = NULL;
device->d3d_initialized = FALSE;
return WINED3D_OK;
@ -4758,13 +4751,10 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
state_unbind_resources(&device->state);
}
if (device->fb.render_targets)
{
for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
{
wined3d_device_set_rendertarget_view(device, i, NULL, FALSE);
}
}
wined3d_device_set_depth_stencil_view(device, NULL);
if (reset_state)

View File

@ -3521,7 +3521,7 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max);
gl_info->limits.buffers = gl_max;
gl_info->limits.buffers = min(MAX_RENDER_TARGET_VIEWS, gl_max);
TRACE("Max draw buffers: %u.\n", gl_max);
}
if (gl_info->supported[ARB_MULTITEXTURE])

View File

@ -271,6 +271,7 @@ static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup
#define MAX_CONSTANT_BUFFERS 15
#define MAX_SAMPLER_OBJECTS 16
#define MAX_SHADER_RESOURCE_VIEWS 128
#define MAX_RENDER_TARGET_VIEWS 8
#define MAX_UNORDERED_ACCESS_VIEWS 8
#define MAX_TGSM_REGISTERS 8192
#define MAX_VERTEX_BLENDS 4
@ -1993,7 +1994,7 @@ struct wined3d_context
struct wined3d_fb_state
{
struct wined3d_rendertarget_view **render_targets;
struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
struct wined3d_rendertarget_view *depth_stencil;
};