From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/adapter_gl.c | 110 +--------- dlls/wined3d/arb_program_shader.c | 27 +-- dlls/wined3d/context_gl.c | 330 ++++++++++-------------------- dlls/wined3d/glsl_shader.c | 27 +-- dlls/wined3d/resource.c | 6 +- dlls/wined3d/shader.c | 4 +- dlls/wined3d/surface.c | 73 +------ dlls/wined3d/swapchain.c | 5 +- dlls/wined3d/texture.c | 34 +-- dlls/wined3d/utils.c | 44 +--- dlls/wined3d/view.c | 10 - dlls/wined3d/wined3d_gl.h | 2 - dlls/wined3d/wined3d_main.c | 1 - dlls/wined3d/wined3d_private.h | 4 - 14 files changed, 137 insertions(+), 540 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index af1a833e410..5539c879199 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -633,8 +633,6 @@ static BOOL match_fbo_tex_update(const struct wined3d_gl_info *gl_info, struct w GLuint tex, fbo; GLenum status;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) return FALSE; - memset(data, 0xcc, sizeof(data));
gl_info->gl_ops.gl.p_glGenTextures(1, &tex); @@ -735,8 +733,6 @@ static BOOL match_broken_arb_fog(const struct wined3d_gl_info *gl_info, struct w "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n" "END\n";
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - return FALSE; if (!gl_info->supported[ARB_FRAGMENT_PROGRAM]) return FALSE; if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) @@ -823,8 +819,6 @@ static BOOL match_broken_viewport_subpixel_bits(const struct wined3d_gl_info *gl { if (!gl_info->supported[ARB_VIEWPORT_ARRAY]) return FALSE; - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - return FALSE; return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx); }
@@ -840,8 +834,6 @@ static BOOL match_no_independent_bit_depths(const struct wined3d_gl_info *gl_inf * relevant case. */ if (!gl_info->supported[ARB_FRAMEBUFFER_OBJECT]) return TRUE; - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - return TRUE;
gl_info->gl_ops.gl.p_glGenTextures(2, tex);
@@ -2905,7 +2897,7 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.general_combiners = gl_max; TRACE("Max general combiners: %d.\n", gl_max); } - if (gl_info->supported[ARB_DRAW_BUFFERS] && wined3d_settings.offscreen_rendering_mode == ORM_FBO) + if (gl_info->supported[ARB_DRAW_BUFFERS]) { gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &gl_max); gl_info->limits.buffers = min(WINED3D_MAX_RENDER_TARGETS, gl_max); @@ -3760,11 +3752,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter_gl *adapter_gl, = gl_info->gl_ops.ext.p_glGetFramebufferAttachmentParameterivEXT; gl_info->fbo_ops.glGenerateMipmap = gl_info->gl_ops.ext.p_glGenerateMipmapEXT; } - else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - WARN_(d3d_perf)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n"); - wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER; - }
if (gl_info->supported[ARB_GEOMETRY_SHADER4]) { @@ -4443,100 +4430,11 @@ static void adapter_gl_get_wined3d_caps(const struct wined3d_adapter *adapter, s } }
-static BOOL wined3d_check_pixel_format_color(const struct wined3d_pixel_format *cfg, - const struct wined3d_format *format) -{ - /* Float formats need FBOs. If FBOs are used this function isn't called */ - if (format->attrs & WINED3D_FORMAT_ATTR_FLOAT) - return FALSE; - - /* Probably a RGBA_float or color index mode. */ - if (cfg->iPixelType != WGL_TYPE_RGBA_ARB) - return FALSE; - - if (cfg->redSize < format->red_size - || cfg->greenSize < format->green_size - || cfg->blueSize < format->blue_size - || cfg->alphaSize < format->alpha_size) - return FALSE; - - return TRUE; -} - -static BOOL wined3d_check_pixel_format_depth(const struct wined3d_pixel_format *cfg, - const struct wined3d_format *format) -{ - BOOL lockable = FALSE; - - /* Float formats need FBOs. If FBOs are used this function isn't called */ - if (format->attrs & WINED3D_FORMAT_ATTR_FLOAT) - return FALSE; - - if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT)) - lockable = TRUE; - - /* On some modern cards like the Geforce8/9, GLX doesn't offer some - * depth/stencil formats which D3D9 reports. We can safely report - * "compatible" formats (e.g. D24 can be used for D16) as long as we - * aren't dealing with a lockable format. This also helps D3D <= 7 as they - * expect D16 which isn't offered without this on Geforce8 cards. */ - if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size))) - return FALSE; - - /* Some cards like Intel i915 ones only offer D24S8 but lots of games also - * need a format without stencil. We can allow a mismatch if the format - * doesn't have any stencil bits. If it does have stencil bits the size - * must match, or stencil wrapping would break. */ - if (format->stencil_size && cfg->stencilSize != format->stencil_size) - return FALSE; - - return TRUE; -} - static BOOL adapter_gl_check_format(const struct wined3d_adapter *adapter, const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format, const struct wined3d_format *ds_format) { - const struct wined3d_adapter_gl *adapter_gl = wined3d_adapter_gl_const(adapter); - unsigned int i; - - if (wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER) - return TRUE; - - if (adapter_format && rt_format) - { - /* In backbuffer mode the front and backbuffer share the same WGL - * pixelformat. The format must match in RGB, alpha is allowed to be - * different. (Only the backbuffer can have alpha.) */ - if (adapter_format->red_size != rt_format->red_size - || adapter_format->green_size != rt_format->green_size - || adapter_format->blue_size != rt_format->blue_size) - { - TRACE("Render target format %s doesn't match with adapter format %s.\n", - debug_d3dformat(rt_format->id), debug_d3dformat(adapter_format->id)); - return FALSE; - } - } - - for (i = 0; i < adapter_gl->pixel_format_count; ++i) - { - const struct wined3d_pixel_format *cfg = &adapter_gl->pixel_formats[i]; - - /* Check if there is a WGL pixel format matching the requirements, the format should also be window - * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */ - if (adapter_format && rt_format && !cfg->windowDrawable) - continue; - - if ((!adapter_format || wined3d_check_pixel_format_color(cfg, adapter_format)) - && (!rt_format || wined3d_check_pixel_format_color(cfg, rt_format)) - && (!ds_format || wined3d_check_pixel_format_depth(cfg, ds_format))) - { - TRACE("Pixel format %d is compatible.\n", cfg->iPixelFormat); - return TRUE; - } - } - - return FALSE; + return TRUE; }
static HRESULT adapter_gl_init_3d(struct wined3d_device *device) @@ -5204,9 +5102,6 @@ static float wined3d_adapter_find_fill_offset(struct wined3d_caps_gl_ctx *ctx) unsigned int upper = ARRAY_SIZE(test_array), lower = 0, test; float value;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - goto end; - while (upper != lower) { test = (upper + lower) / 2; @@ -5231,7 +5126,6 @@ static float wined3d_adapter_find_fill_offset(struct wined3d_caps_gl_ctx *ctx)
FIXME("Did not find a way to get the filling convention we want.\n");
-end: /* This value was used unconditionally before the dynamic test function was * introduced. */ return -1.0f / 64.0f; diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 4e5e3482dfd..fd58f8b080b 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7691,12 +7691,6 @@ static BOOL arbfp_blit_supported(enum wined3d_blit_op blit_op, const struct wine /* We only support YUV conversions. */ if (!is_complex_fixup(src_format->color_fixup)) { - if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) - { - WARN("Claiming fixup support because of ORM_BACKBUFFER.\n"); - return TRUE; - } - TRACE("[FAILED]\n"); return FALSE; } @@ -7733,7 +7727,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl struct wined3d_color_key alpha_test_key; struct wined3d_blitter *next; unsigned int src_level; - RECT s, d; + RECT d;
TRACE("blitter %p, op %#x, context %p, src_texture %p, src_sub_resource_idx %u, src_location %s, " "src_rect %s, dst_texture %p, dst_sub_resource_idx %u, dst_location %s, dst_rect %s, " @@ -7794,25 +7788,6 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl src_texture_gl = wined3d_texture_gl(src_texture); src_sub_resource_idx = 0; } - else if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - && (src_texture->sub_resources[src_sub_resource_idx].locations - & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_DRAWABLE)) == WINED3D_LOCATION_DRAWABLE - && !wined3d_resource_is_offscreen(&src_texture->resource)) - { - - /* Without FBO blits transferring from the drawable to the texture is - * expensive, because we have to flip the data in sysmem. Since we can - * flip in the blitter, we don't actually need that flip anyway. So we - * use the surface's texture as scratch texture, and flip the source - * rectangle instead. */ - texture2d_load_fb_texture(src_texture_gl, src_sub_resource_idx, FALSE, context); - - s = *src_rect; - src_level = src_sub_resource_idx % src_texture->level_count; - s.top = wined3d_texture_get_level_height(src_texture, src_level) - s.top; - s.bottom = wined3d_texture_get_level_height(src_texture, src_level) - s.bottom; - src_rect = &s; - } else { wined3d_texture_load(src_texture, context, FALSE); diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index a1561f78133..a7caef64b46 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1937,7 +1937,6 @@ static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context struct wined3d_device *device; bool swap_effect_copy; HGLRC ctx, share_ctx; - unsigned int i;
device = context->device; adapter = device->adapter; @@ -1950,73 +1949,18 @@ static BOOL wined3d_context_gl_create_wgl_ctx(struct wined3d_context_gl *context
*new_drawable = !GetPixelFormat(context_gl->dc);
- if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) - { - static const enum wined3d_format_id ds_formats[] = - { - WINED3DFMT_D24_UNORM_S8_UINT, - WINED3DFMT_D32_UNORM, - WINED3DFMT_R24_UNORM_X8_TYPELESS, - WINED3DFMT_D16_UNORM, - WINED3DFMT_S1_UINT_D15_UNORM, - }; - - colour_format = target->format; - - /* In case of ORM_BACKBUFFER, make sure to request an alpha component for - * X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */ - if (colour_format->id == WINED3DFMT_B4G4R4X4_UNORM) - colour_format = wined3d_get_format(adapter, WINED3DFMT_B4G4R4A4_UNORM, target_bind_flags); - else if (colour_format->id == WINED3DFMT_B8G8R8X8_UNORM) - colour_format = wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, target_bind_flags); - - /* DirectDraw supports 8bit paletted render targets and these are used by - * old games like StarCraft and C&C. Most modern hardware doesn't support - * 8bit natively so we perform some form of 8bit -> 32bit conversion. The - * conversion (ab)uses the alpha component for storing the palette index. - * For this reason we require a format with 8bit alpha, so request - * A8R8G8B8. */ - if (colour_format->id == WINED3DFMT_P8_UINT) - colour_format = wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, target_bind_flags); - - /* Try to find a pixel format which matches our requirements. */ - if (!swapchain_gl->s.ds_format) - { - for (i = 0; i < ARRAY_SIZE(ds_formats); ++i) - { - ds_format = wined3d_get_format(adapter, ds_formats[i], WINED3D_BIND_DEPTH_STENCIL); - if ((context_gl->pixel_format = context_choose_pixel_format(device, - context_gl->dc, colour_format, ds_format, true, swap_effect_copy))) - { - swapchain_gl->s.ds_format = ds_format; - break; - } - - TRACE("Depth stencil format %s is not supported, trying next format.\n", - debug_d3dformat(ds_format->id)); - } - } - else - { - context_gl->pixel_format = context_choose_pixel_format(device, - context_gl->dc, colour_format, swapchain_gl->s.ds_format, true, swap_effect_copy); - } - } - else - { - /* When using FBOs for off-screen rendering, we only use the drawable for - * presentation blits, and don't do any rendering to it. That means we - * don't need depth or stencil buffers, and can mostly ignore the render - * target format. This wouldn't necessarily be quite correct for 10bpc - * display modes, but we don't currently support those. - * Using the same format regardless of the colour/depth/stencil targets - * makes it much less likely that different wined3d instances will set - * conflicting pixel formats. */ - colour_format = wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, target_bind_flags); - ds_format = wined3d_get_format(adapter, WINED3DFMT_UNKNOWN, WINED3D_BIND_DEPTH_STENCIL); - context_gl->pixel_format = context_choose_pixel_format(device, - context_gl->dc, colour_format, ds_format, false, swap_effect_copy); - } + /* When using FBOs for off-screen rendering, we only use the drawable for + * presentation blits, and don't do any rendering to it. That means we + * don't need depth or stencil buffers, and can mostly ignore the render + * target format. This wouldn't necessarily be quite correct for 10bpc + * display modes, but we don't currently support those. + * Using the same format regardless of the colour/depth/stencil targets + * makes it much less likely that different wined3d instances will set + * conflicting pixel formats. */ + colour_format = wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, target_bind_flags); + ds_format = wined3d_get_format(adapter, WINED3DFMT_UNKNOWN, WINED3D_BIND_DEPTH_STENCIL); + context_gl->pixel_format = context_choose_pixel_format(device, + context_gl->dc, colour_format, ds_format, false, swap_effect_copy);
if (!context_gl->pixel_format) { @@ -2500,33 +2444,26 @@ static void wined3d_context_gl_apply_draw_buffers(struct wined3d_context_gl *con } else { - if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - unsigned int i = 0; + unsigned int i = 0;
- while (rt_mask) - { - if (rt_mask & 1) - draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i; - else - draw_buffers[i] = GL_NONE; + while (rt_mask) + { + if (rt_mask & 1) + draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i; + else + draw_buffers[i] = GL_NONE;
- rt_mask >>= 1; - ++i; - } + rt_mask >>= 1; + ++i; + }
- if (gl_info->supported[ARB_DRAW_BUFFERS]) - { - GL_EXTCALL(glDrawBuffers(i, draw_buffers)); - } - else - { - gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]); - } + if (gl_info->supported[ARB_DRAW_BUFFERS]) + { + GL_EXTCALL(glDrawBuffers(i, draw_buffers)); } else { - ERR("Unexpected draw buffers mask with backbuffer ORM.\n"); + gl_info->gl_ops.gl.p_glDrawBuffer(draw_buffers[0]); } }
@@ -3239,18 +3176,7 @@ static void wined3d_context_gl_set_render_offscreen(struct wined3d_context_gl *c
GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) { - switch (wined3d_settings.offscreen_rendering_mode) - { - case ORM_FBO: - return GL_COLOR_ATTACHMENT0; - - case ORM_BACKBUFFER: - return context_gl->aux_buffers > 0 ? GL_AUX0 : GL_BACK; - - default: - FIXME("Unhandled offscreen rendering mode %#x.\n", wined3d_settings.offscreen_rendering_mode); - return GL_BACK; - } + return GL_COLOR_ATTACHMENT0; }
static uint32_t wined3d_context_gl_generate_rt_mask_no_fbo(const struct wined3d_context_gl *context_gl, @@ -3493,64 +3419,56 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, if (isStateDirty(&context_gl->c, STATE_FRAMEBUFFER) || fb != &state->fb || rt_count != gl_info->limits.buffers) { + struct wined3d_rendertarget_info ds_info = {{0}}; + if (!have_framebuffer_attachment(rt_count, rts, dsv)) { WARN("Invalid render target config, need at least one attachment.\n"); return FALSE; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)) { - struct wined3d_rendertarget_info ds_info = {{0}}; - - if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)) + memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); + for (i = 0; i < rt_count; ++i) { - memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); - for (i = 0; i < rt_count; ++i) + if (rts[i]) { - if (rts[i]) - { - struct wined3d_rendertarget_view_gl *rtv_gl = wined3d_rendertarget_view_gl(rts[i]); - context_gl->blit_targets[i].gl_view = rtv_gl->gl_view; - context_gl->blit_targets[i].resource = rtv_gl->v.resource; - context_gl->blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx; - context_gl->blit_targets[i].layer_count = rtv_gl->v.layer_count; - } - if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL) - rt_mask |= (1u << i); + struct wined3d_rendertarget_view_gl *rtv_gl = wined3d_rendertarget_view_gl(rts[i]); + context_gl->blit_targets[i].gl_view = rtv_gl->gl_view; + context_gl->blit_targets[i].resource = rtv_gl->v.resource; + context_gl->blit_targets[i].sub_resource_idx = rtv_gl->v.sub_resource_idx; + context_gl->blit_targets[i].layer_count = rtv_gl->v.layer_count; } - - if (dsv) - { - 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; - } - - wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, - rt_count ? rts[0]->resource->draw_binding : 0, dsv ? dsv->resource->draw_binding : 0); + if (rts[i] && rts[i]->format->id != WINED3DFMT_NULL) + rt_mask |= (1u << i); } - else + + if (dsv) { - wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, NULL, &ds_info, - WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE); - rt_mask = context_generate_rt_mask_from_resource(rts[0]->resource); + 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; }
- /* If the framebuffer is not the device's fb the device's fb has to be reapplied - * next draw. Otherwise we could mark the framebuffer state clean here, once the - * state management allows this */ - context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER); + wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, + rt_count ? rts[0]->resource->draw_binding : 0, dsv ? dsv->resource->draw_binding : 0); } else { - rt_mask = wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, rt_count ? rts[0]->resource : NULL); + wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, NULL, &ds_info, + WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE); + rt_mask = context_generate_rt_mask_from_resource(rts[0]->resource); } + + /* If the framebuffer is not the device's fb the device's fb has to be reapplied + * next draw. Otherwise we could mark the framebuffer state clean here, once the + * state management allows this */ + context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER); } - else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO - && (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource))) + else if (!rt_count || wined3d_resource_is_offscreen(rts[0]->resource)) { for (i = 0; i < rt_count; ++i) { @@ -3572,8 +3490,7 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER); }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - wined3d_context_gl_check_fbo_status(context_gl, GL_FRAMEBUFFER); + wined3d_context_gl_check_fbo_status(context_gl, GL_FRAMEBUFFER);
context_gl->c.last_was_blit = FALSE; context_gl->c.last_was_ffp_blit = FALSE; @@ -3608,9 +3525,7 @@ static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_ unsigned int rt_mask, mask; unsigned int i;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - return wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, rts[0]->resource); - else if (!context_gl->c.render_offscreen) + if (!context_gl->c.render_offscreen) return context_generate_rt_mask_from_resource(rts[0]->resource);
rt_mask = ps ? ps->reg_maps.rt_mask : 1; @@ -3639,33 +3554,23 @@ void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl, TRACE("context_gl %p, texture %p, sub_resource_idx %u, location %s.\n", context_gl, texture, sub_resource_idx, wined3d_debug_location(location));
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - if (format->depth_size || format->stencil_size) - wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_DRAW_FRAMEBUFFER, NULL, - 0, &texture->resource, sub_resource_idx, location); - else - wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_DRAW_FRAMEBUFFER, &texture->resource, - sub_resource_idx, NULL, 0, location); - } + if (format->depth_size || format->stencil_size) + wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_DRAW_FRAMEBUFFER, NULL, + 0, &texture->resource, sub_resource_idx, location); + else + wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_DRAW_FRAMEBUFFER, &texture->resource, + sub_resource_idx, NULL, 0, location);
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + if (location != WINED3D_LOCATION_DRAWABLE) { - if (location != WINED3D_LOCATION_DRAWABLE) - { - if (texture->resource.format->id == WINED3DFMT_NULL || format->depth_size || format->stencil_size) - rt_mask = 0; - else - rt_mask = 1; - } + if (texture->resource.format->id == WINED3DFMT_NULL || format->depth_size || format->stencil_size) + rt_mask = 0; else - { - rt_mask = context_generate_rt_mask_from_resource(&texture->resource); - } + rt_mask = 1; } else { - rt_mask = wined3d_context_gl_generate_rt_mask_no_fbo(context_gl, &texture->resource); + rt_mask = context_generate_rt_mask_from_resource(&texture->resource); }
cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask; @@ -3675,8 +3580,7 @@ void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl, *cur_mask = rt_mask; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER); + wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
context_invalidate_state(context, STATE_FRAMEBUFFER); } @@ -3686,52 +3590,48 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); uint32_t rt_mask = find_draw_buffers_mask(context_gl, state); + struct wined3d_rendertarget_info ds_info = {{0}}; const struct wined3d_fb_state *fb = &state->fb; DWORD color_location = 0; uint32_t *cur_mask;
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + if (!context->render_offscreen) { - struct wined3d_rendertarget_info ds_info = {{0}}; + wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, NULL, &ds_info, + WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE); + } + else + { + const struct wined3d_rendertarget_view_gl *view_gl; + unsigned int i;
- if (!context->render_offscreen) - { - wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, NULL, &ds_info, - WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE); - } - else + memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); + for (i = 0; i < context_gl->gl_info->limits.buffers; ++i) { - const struct wined3d_rendertarget_view_gl *view_gl; - unsigned int i; - - memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); - for (i = 0; i < context_gl->gl_info->limits.buffers; ++i) - { - if (!fb->render_targets[i]) - continue; - - view_gl = wined3d_rendertarget_view_gl(fb->render_targets[i]); - context_gl->blit_targets[i].gl_view = view_gl->gl_view; - context_gl->blit_targets[i].resource = view_gl->v.resource; - context_gl->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx; - context_gl->blit_targets[i].layer_count = view_gl->v.layer_count; + if (!fb->render_targets[i]) + continue;
- if (!color_location) - color_location = view_gl->v.resource->draw_binding; - } + view_gl = wined3d_rendertarget_view_gl(fb->render_targets[i]); + context_gl->blit_targets[i].gl_view = view_gl->gl_view; + context_gl->blit_targets[i].resource = view_gl->v.resource; + context_gl->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx; + context_gl->blit_targets[i].layer_count = view_gl->v.layer_count;
- if (fb->depth_stencil) - { - 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; - } + if (!color_location) + color_location = view_gl->v.resource->draw_binding; + }
- wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, - color_location, fb->depth_stencil ? fb->depth_stencil->resource->draw_binding : 0); + if (fb->depth_stencil) + { + 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; } + + wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, + color_location, fb->depth_stencil ? fb->depth_stencil->resource->draw_binding : 0); }
cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask; @@ -4437,8 +4337,7 @@ static BOOL context_apply_draw_state(struct wined3d_context *context, context->update_compute_unordered_access_view_bindings = 1; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - wined3d_context_gl_check_fbo_status(context_gl, GL_FRAMEBUFFER); + wined3d_context_gl_check_fbo_status(context_gl, GL_FRAMEBUFFER);
/* WINED3D_SHADER_CONST_PS_NP2_FIXUP may be set when binding shader * resources, so constant loading needs to be done after that. */ @@ -4574,27 +4473,6 @@ static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_g || !(texture->resource.format_caps & WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING)) context_invalidate_state(&context_gl->c, STATE_BLEND); } - - /* When switching away from an offscreen render target, and we're not - * using FBOs, we have to read the drawable into the texture. This is - * done via PreLoad (and WINED3D_LOCATION_DRAWABLE set on the surface). - * There are some things that need care though. PreLoad needs a GL context, - * and FindContext is called before the context is activated. It also - * has to be called with the old rendertarget active, otherwise a - * wrong drawable is read. */ - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - && old_render_offscreen && (context_gl->c.current_rt.texture != texture - || context_gl->c.current_rt.sub_resource_idx != sub_resource_idx)) - { - struct wined3d_texture_gl *prev_texture = wined3d_texture_gl(context_gl->c.current_rt.texture); - unsigned int prev_sub_resource_idx = context_gl->c.current_rt.sub_resource_idx; - - /* Read the back buffer of the old drawable into the destination texture. */ - if (prev_texture->texture_srgb.name) - wined3d_texture_load(&prev_texture->t, &context_gl->c, TRUE); - wined3d_texture_load(&prev_texture->t, &context_gl->c, FALSE); - wined3d_texture_invalidate_location(&prev_texture->t, prev_sub_resource_idx, WINED3D_LOCATION_DRAWABLE); - } }
context_gl->c.current_rt.texture = texture; diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6d582896bb2..21006d3cf46 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -8019,8 +8019,7 @@ static GLuint shader_glsl_generate_fragment_shader(const struct wined3d_context_ shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[1].x, 4, gl_info); shader_addline(buffer, ";\n"); } - if ((reg_maps->usesdsy && wined3d_settings.offscreen_rendering_mode != ORM_FBO) - || (reg_maps->vpos && !gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS])) + if (reg_maps->vpos && !gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) { ++extra_constants_needed; shader_addline(buffer, "uniform vec4 ycorrection;\n"); @@ -13418,8 +13417,7 @@ static BOOL glsl_blitter_supported(enum wined3d_blit_op blit_op, const struct wi return FALSE; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO - && !((dst_format->caps[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3D_FORMAT_CAP_FBO_ATTACHABLE) + if (!((dst_format->caps[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3D_FORMAT_CAP_FBO_ATTACHABLE) || (dst_resource->bind_flags & WINED3D_BIND_RENDER_TARGET))) { TRACE("Destination texture is not FBO attachable.\n"); @@ -13449,7 +13447,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli struct wined3d_blitter *next; unsigned int src_level; GLint location; - RECT s, d; + RECT d;
TRACE("blitter %p, op %#x, context %p, src_texture %p, src_sub_resource_idx %u, src_location %s, " "src_rect %s, dst_texture %p, dst_sub_resource_idx %u, dst_location %s, dst_rect %s, " @@ -13510,25 +13508,6 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli src_texture_gl = wined3d_texture_gl(src_texture); src_sub_resource_idx = 0; } - else if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - && (src_texture->sub_resources[src_sub_resource_idx].locations - & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_DRAWABLE)) == WINED3D_LOCATION_DRAWABLE - && !wined3d_resource_is_offscreen(&src_texture->resource)) - { - - /* Without FBO blits transferring from the drawable to the texture is - * expensive, because we have to flip the data in sysmem. Since we can - * flip in the blitter, we don't actually need that flip anyway. So we - * use the surface's texture as scratch texture, and flip the source - * rectangle instead. */ - texture2d_load_fb_texture(src_texture_gl, src_sub_resource_idx, FALSE, context); - - s = *src_rect; - src_level = src_sub_resource_idx % src_texture->level_count; - s.top = wined3d_texture_get_level_height(src_texture, src_level) - s.top; - s.bottom = wined3d_texture_get_level_height(src_texture, src_level) - s.bottom; - src_rect = &s; - } else { wined3d_texture_load(src_texture, context, FALSE); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index bd8391ec3b3..e336e0048e0 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -436,16 +436,14 @@ BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) if (resource == &swapchain->front_buffer->resource) return FALSE;
- /* If the swapchain is rendered to an FBO, the backbuffer is - * offscreen, otherwise onscreen */ - return wined3d_settings.offscreen_rendering_mode == ORM_FBO; + return TRUE; }
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) { const struct wined3d_d3d_info *d3d_info = &resource->device->adapter->d3d_info;
- if (!wined3d_resource_is_offscreen(resource) || wined3d_settings.offscreen_rendering_mode != ORM_FBO) + if (!wined3d_resource_is_offscreen(resource)) { resource->draw_binding = WINED3D_LOCATION_DRAWABLE; } diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index e6a3b4a33bb..a5dabc1f344 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3056,9 +3056,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 if (d3d_info->emulated_flatshading) args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
- args->y_correction = (shader->reg_maps.vpos && d3d_info->frag_coord_correction) - || (shader->reg_maps.usesdsy && wined3d_settings.offscreen_rendering_mode != ORM_FBO) - ? !context->render_offscreen : 0; + args->y_correction = (shader->reg_maps.vpos && d3d_info->frag_coord_correction) ? !context->render_offscreen : 0;
for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i) { diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index e413689599d..b37a84b0086 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -375,15 +375,12 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i context_gl = wined3d_context_gl(context); gl_info = context_gl->gl_info;
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - if (resource->format->depth_size || resource->format->stencil_size) - wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_READ_FRAMEBUFFER, - NULL, 0, resource, sub_resource_idx, src_location); - else - wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_READ_FRAMEBUFFER, - resource, sub_resource_idx, NULL, 0, src_location); - } + if (resource->format->depth_size || resource->format->stencil_size) + wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_READ_FRAMEBUFFER, + NULL, 0, resource, sub_resource_idx, src_location); + else + wined3d_context_gl_apply_fbo_state_explicit(context_gl, GL_READ_FRAMEBUFFER, + resource, sub_resource_idx, NULL, 0, src_location);
/* Select the correct read buffer, and give some debug output. There is no * need to keep track of the current read buffer or reset it, every part @@ -405,8 +402,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i src_is_upside_down = FALSE; } checkGLcall("glReadBuffer"); - if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER); + wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER);
if (data.buffer_object) { @@ -481,58 +477,6 @@ error: context_restore(context, restore_texture, restore_idx); }
-/* Read the framebuffer contents into a texture. Note that this function - * doesn't do any kind of flipping. Using this on an onscreen surface will - * result in a flipped D3D texture. - * - * Context activation is done by the caller. This function may temporarily - * switch to a different context and restore the original one before return. */ -void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, - unsigned int sub_resource_idx, BOOL srgb, struct wined3d_context *context) -{ - struct wined3d_texture *restore_texture; - const struct wined3d_gl_info *gl_info; - struct wined3d_context_gl *context_gl; - struct wined3d_resource *resource; - unsigned int restore_idx, level; - struct wined3d_device *device; - GLenum target; - - resource = &texture_gl->t.resource; - device = resource->device; - restore_texture = context->current_rt.texture; - restore_idx = context->current_rt.sub_resource_idx; - if (restore_texture != &texture_gl->t || restore_idx != sub_resource_idx) - context = context_acquire(device, &texture_gl->t, sub_resource_idx); - else - restore_texture = NULL; - context_gl = wined3d_context_gl(context); - - gl_info = context_gl->gl_info; - device_invalidate_state(device, STATE_FRAMEBUFFER); - - wined3d_texture_gl_prepare_texture(texture_gl, context_gl, srgb); - wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb); - - TRACE("Reading back offscreen render target %p, %u.\n", texture_gl, sub_resource_idx); - - if (wined3d_resource_is_offscreen(resource)) - gl_info->gl_ops.gl.p_glReadBuffer(wined3d_context_gl_get_offscreen_gl_buffer(context_gl)); - else - gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(&texture_gl->t)); - checkGLcall("glReadBuffer"); - - level = sub_resource_idx % texture_gl->t.level_count; - target = wined3d_texture_gl_get_sub_resource_target(texture_gl, sub_resource_idx); - gl_info->gl_ops.gl.p_glCopyTexSubImage2D(target, level, 0, 0, 0, 0, - wined3d_texture_get_level_width(&texture_gl->t, level), - wined3d_texture_get_level_height(&texture_gl->t, level)); - checkGLcall("glCopyTexSubImage2D"); - - if (restore_texture) - context_restore(context, restore_texture, restore_idx); -} - /* Context activation is done by the caller. */ static void cpu_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_context *context) { @@ -1467,8 +1411,7 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_ dst_swapchain = dst_texture->swapchain;
if (src_swapchain && dst_swapchain && src_swapchain != dst_swapchain - && (wined3d_settings.offscreen_rendering_mode != ORM_FBO - || src_texture == src_swapchain->front_buffer)) + && src_texture == src_swapchain->front_buffer) { /* TODO: We could support cross-swapchain blits by first downloading * the source to a texture. */ diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index c18ac0afefc..6b2ad8d6954 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -523,7 +523,7 @@ static void wined3d_swapchain_gl_rotate(struct wined3d_swapchain *swapchain, str unsigned int i; static const DWORD supported_locations = WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_RB_MULTISAMPLE;
- if (swapchain->state.desc.backbuffer_count < 2 || wined3d_settings.offscreen_rendering_mode != ORM_FBO) + if (swapchain->state.desc.backbuffer_count < 2) return;
texture_prev = wined3d_texture_gl(swapchain->back_buffers[0]); @@ -615,8 +615,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
wined3d_texture_load_location(back_buffer, 0, context, back_buffer->resource.draw_binding);
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - swapchain_blit(swapchain, context, src_rect, dst_rect); + swapchain_blit(swapchain, context, src_rect, dst_rect);
if (swapchain->device->context_count > 1) { diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 2fc6d5c06df..9edfc38c01c 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -287,9 +287,6 @@ static bool fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct win const struct wined3d_format *dst_format = dst_resource->format; bool src_ds, dst_ds;
- if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer) - return false; - if ((src_resource->format_attrs | dst_resource->format_attrs) & WINED3D_FORMAT_ATTR_HEIGHT_SCALE) return false;
@@ -3037,8 +3034,7 @@ static BOOL wined3d_texture_load_drawable(struct wined3d_texture *texture, return FALSE; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO - && wined3d_resource_is_offscreen(&texture->resource)) + if (wined3d_resource_is_offscreen(&texture->resource)) { ERR("Trying to load offscreen texture into WINED3D_LOCATION_DRAWABLE.\n"); return FALSE; @@ -3112,16 +3108,6 @@ static BOOL wined3d_texture_gl_load_texture(struct wined3d_texture_gl *texture_g
depth = texture_gl->t.resource.bind_flags & WINED3D_BIND_DEPTH_STENCIL; sub_resource = &texture_gl->t.sub_resources[sub_resource_idx]; - - if (!depth && wined3d_settings.offscreen_rendering_mode != ORM_FBO - && wined3d_resource_is_offscreen(&texture_gl->t.resource) - && (sub_resource->locations & WINED3D_LOCATION_DRAWABLE)) - { - texture2d_load_fb_texture(texture_gl, sub_resource_idx, srgb, &context_gl->c); - - return TRUE; - } - level = sub_resource_idx % texture_gl->t.level_count; wined3d_texture_get_level_box(&texture_gl->t, level, &src_box);
@@ -3269,7 +3255,7 @@ static BOOL wined3d_texture_gl_prepare_location(struct wined3d_texture *texture, return TRUE;
case WINED3D_LOCATION_DRAWABLE: - if (!texture->swapchain && wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER) + if (!texture->swapchain) ERR("Texture %p does not have a drawable.\n", texture); return TRUE;
@@ -3292,12 +3278,6 @@ static bool use_ffp_clear(const struct wined3d_texture *texture, unsigned int lo if (location == WINED3D_LOCATION_DRAWABLE) return true;
- /* If we are not using FBOs (and not rendering to the drawable), always - * upload. The upload should always succeed in this case; we cannot have - * ARB_texture_multisample without ARB_framebuffer_object. */ - if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - return false; - if (location == WINED3D_LOCATION_TEXTURE_RGB && !(texture->resource.format_caps & WINED3D_FORMAT_CAP_FBO_ATTACHABLE)) return false; @@ -5859,9 +5839,7 @@ static bool ffp_blit_supported(enum wined3d_blit_op blit_op, const struct wined3 { if (dst_format->id == src_format->id && dst_location == WINED3D_LOCATION_DRAWABLE) { - if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) - WARN("Claiming fixup support because of ORM_BACKBUFFER.\n"); - else if (context->device->shader_backend == &none_shader_backend) + if (context->device->shader_backend == &none_shader_backend) WARN("Claiming fixup support because of no shader backend.\n"); return true; } @@ -6173,8 +6151,7 @@ static void ffp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_de
if (blitter_use_cpu_clear(view) || (!(view->resource->bind_flags & WINED3D_BIND_RENDER_TARGET) - && (wined3d_settings.offscreen_rendering_mode != ORM_FBO - || !(view->format_caps & WINED3D_FORMAT_CAP_FBO_ATTACHABLE)))) + && !(view->format_caps & WINED3D_FORMAT_CAP_FBO_ATTACHABLE))) { next_flags |= WINED3DCLEAR_TARGET; flags &= ~WINED3DCLEAR_TARGET; @@ -6523,9 +6500,6 @@ void wined3d_fbo_blitter_create(struct wined3d_blitter **next, const struct wine { struct wined3d_blitter *blitter;
- if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer) - return; - if (!(blitter = malloc(sizeof(*blitter)))) return;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index dcbc177d29e..8af50fbbf06 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -2905,13 +2905,10 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter, return; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - 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); - } + 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);
for (i = 0; i < WINED3D_FORMAT_COUNT; ++i) { @@ -2927,19 +2924,11 @@ static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter, continue; }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - { - TRACE("Checking if format %s is supported as FBO color attachment...\n", debug_d3dformat(format->f.id)); - check_fbo_compat(ctx, format); - } - else - { - format->rt_internal = format->internal; - } + TRACE("Checking if format %s is supported as FBO color attachment...\n", debug_d3dformat(format->f.id)); + check_fbo_compat(ctx, format); }
- if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) - gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo); + gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo); }
static GLenum lookup_gl_view_class(GLenum internal_format) @@ -3136,8 +3125,7 @@ static void query_internal_format(struct wined3d_adapter *adapter, format_clear_caps(&format->f, WINED3D_FORMAT_CAP_SRGB_WRITE); }
- if ((!gl_info->supported[ARB_DEPTH_TEXTURE] || wined3d_settings.offscreen_rendering_mode != ORM_FBO) - && (format->f.depth_size || format->f.stencil_size)) + if (!gl_info->supported[ARB_DEPTH_TEXTURE] && (format->f.depth_size || format->f.stencil_size)) { TRACE("Disabling texturing support for depth / stencil format %s.\n", debug_d3dformat(format->f.id)); format->f.caps[WINED3D_GL_RES_TYPE_TEX_1D] &= ~WINED3D_FORMAT_CAP_TEXTURE; @@ -3151,8 +3139,7 @@ static void query_internal_format(struct wined3d_adapter *adapter,
if (format->internal && format->f.caps[WINED3D_GL_RES_TYPE_RB] & (WINED3D_FORMAT_CAP_RENDERTARGET | WINED3D_FORMAT_CAP_DEPTH_STENCIL) - && (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE]) - && wined3d_settings.offscreen_rendering_mode == ORM_FBO) + && (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] || gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])) { if (gl_info->supported[ARB_INTERNALFORMAT_QUERY]) { @@ -3215,10 +3202,6 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win && (format->f.attrs & WINED3D_FORMAT_ATTR_INTEGER)) continue;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - && (format->f.id == WINED3DFMT_D16_LOCKABLE || format->f.id == WINED3DFMT_NULL)) - continue; - format->internal = format_texture_info[i].gl_internal; format->srgb_internal = format_texture_info[i].gl_srgb_internal; format->rt_internal = format_texture_info[i].gl_rt_internal; @@ -3424,8 +3407,7 @@ static void init_format_filter_info(struct wined3d_adapter *adapter, if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2]) return;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO - || !gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) + if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) { if (vendor == HW_VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) { @@ -4043,12 +4025,6 @@ static float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *c * Nvidia. Use this as a fallback if the detection fails. */ unsigned int fallback = 23;
- if (wined3d_settings.offscreen_rendering_mode != ORM_FBO) - { - FIXME("No FBOs, assuming polyoffset scale of 2^%u.\n", fallback); - return (float)(1u << fallback); - } - gl_info->gl_ops.gl.p_glGenTextures(1, &color); gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, color); gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 09d1bfd32a1..73fd6d1125c 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -465,16 +465,6 @@ void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarg *width = texture->resource.width; *height = texture->resource.height; } - else if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) - { - const struct wined3d_swapchain_desc *desc = &context->swapchain->state.desc; - - /* The drawable size of a backbuffer / aux buffer offscreen target is - * the size of the current context's drawable, which is the size of - * the back buffer of the swapchain the active context belongs to. */ - *width = desc->backbuffer_width; - *height = desc->backbuffer_height; - } else { unsigned int level_idx = view->sub_resource_idx % texture->level_count; diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 772e79e80a3..ab04315a7e9 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -1042,8 +1042,6 @@ struct wined3d_blt_info
void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *rect, struct wined3d_blt_info *info); -void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, - BOOL srgb, struct wined3d_context *context); void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD src_location, DWORD dst_location);
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index cd20fe8b80d..863428bb53a 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -117,7 +117,6 @@ struct wined3d_settings wined3d_settings = { .cs_multithreaded = WINED3D_CSMT_ENABLE, .max_gl_version = MAKEDWORD_VERSION(4, 4), - .offscreen_rendering_mode = ORM_FBO, .pci_vendor_id = PCI_VENDOR_NONE, .pci_device_id = PCI_DEVICE_NONE, .multisample_textures = TRUE, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 5f0c88eda97..83bc6a95efd 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -456,9 +456,6 @@ static inline int wined3d_uint64_compare(uint64_t x, uint64_t y) return (x > y) - (x < y); }
-#define ORM_BACKBUFFER 0 -#define ORM_FBO 1 - #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */ #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
@@ -478,7 +475,6 @@ struct wined3d_settings { unsigned int cs_multithreaded; unsigned int max_gl_version; - int offscreen_rendering_mode; unsigned short pci_vendor_id; unsigned short pci_device_id; /* Memory tracking and object counting. */
From: Elizabeth Figura zfigura@codeweavers.com
This is the only user of context->render_offscreen that is not related to draw state.
The use here is synonymous with using wined3d_resource_is_offscreen() on the actual colour target. --- dlls/wined3d/texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 9edfc38c01c..a4eee054528 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -5955,7 +5955,7 @@ static void ffp_blitter_clear_rendertargets(struct wined3d_device *device, unsig
if (target) { - render_offscreen = context->render_offscreen; + render_offscreen = wined3d_resource_is_offscreen(&target->resource); wined3d_rendertarget_view_get_drawable_size(rtv, context, &drawable_width, &drawable_height); } else
From: Elizabeth Figura zfigura@codeweavers.com
Now that we require ORM_FBO, wined3d backbuffers are always offscreen (and we never draw directly to the frontbuffer, which is the only truly onscreen surface).
We could reintroduce support for drawing directly to the backbuffer, and this would presumably improve performance by avoiding a blit from the wined3d backbuffer to the real GL backbuffer.
However, this is not always possible or performant due to mismatching dimensions, or the need to use a depth buffer which is also used with offscreen RTVs, and for d3d1-9 it may not be possible at all due to issues related to preserving invariance between flipped and non-flipped geometry.
It *may* be possible to identify situations where we can render directly to the backbuffer for d3d10+, but at that point we can rely on the Vulkan backend to work, and given other unfixable performance problems with the GL backend (most notably the inability to properly stream index buffer data) it does not really make much sense to go out of our way to perform such a minor optimization there. --- dlls/wined3d/adapter_gl.c | 1 - dlls/wined3d/arb_program_shader.c | 4 +- dlls/wined3d/context_gl.c | 101 +++++++++--------------------- dlls/wined3d/ffp_gl.c | 95 +++++++--------------------- dlls/wined3d/glsl_shader.c | 4 +- dlls/wined3d/shader.c | 4 +- dlls/wined3d/utils.c | 2 +- dlls/wined3d/wined3d_private.h | 10 +-- 8 files changed, 60 insertions(+), 161 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index 5539c879199..06e18c30d68 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -5060,7 +5060,6 @@ static void wined3d_adapter_gl_init_d3d_info(struct wined3d_adapter_gl *adapter_ d3d_info->vs_clipping = shader_caps.wined3d_caps & WINED3D_SHADER_CAP_VS_CLIPPING; d3d_info->shader_double_precision = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_DOUBLE_PRECISION); d3d_info->shader_output_interpolation = !!(shader_caps.wined3d_caps & WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION); - d3d_info->frag_coord_correction = !!gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]; d3d_info->viewport_array_index_any_shader = !!gl_info->supported[ARB_SHADER_VIEWPORT_LAYER_ARRAY]; d3d_info->stencil_export = !!gl_info->supported[ARB_SHADER_STENCIL_EXPORT]; d3d_info->texture_npot = !!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]; diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index fd58f8b080b..305322522cb 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -561,8 +561,8 @@ static void shader_arb_ps_local_constants(const struct arb_ps_compiled_shader *g * ycorrection.w: 0.0 */ float val[4]; - val[0] = context_gl->c.render_offscreen ? 0.0f : (float)rt_height; - val[1] = context_gl->c.render_offscreen ? 1.0f : -1.0f; + val[0] = 0.0f; + val[1] = 1.0f; val[2] = 1.0f; val[3] = 0.0f; GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, gl_shader->ycorrection, val)); diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index a7caef64b46..6f7cf0eb3e3 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -2122,7 +2122,6 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wi
/* Set up the context defaults. */
- context->render_offscreen = wined3d_resource_is_offscreen(&context->current_rt.texture->resource); context_gl->draw_buffers_mask = context_generate_rt_mask(GL_BACK);
if (!wined3d_context_gl_set_current(context_gl)) @@ -3155,25 +3154,6 @@ void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct bo->id = 0; }
-static void wined3d_context_gl_set_render_offscreen(struct wined3d_context_gl *context_gl, BOOL offscreen) -{ - if (context_gl->c.render_offscreen == offscreen) - return; - - context_invalidate_state(&context_gl->c, STATE_VIEWPORT); - context_invalidate_state(&context_gl->c, STATE_SCISSORRECT); - if (!context_gl->gl_info->supported[ARB_CLIP_CONTROL]) - { - context_invalidate_state(&context_gl->c, STATE_RASTERIZER); - context_invalidate_state(&context_gl->c, STATE_POINTSPRITECOORDORIGIN); - context_invalidate_state(&context_gl->c, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); - } - context_invalidate_state(&context_gl->c, STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN)); - if (context_gl->gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) - context_invalidate_state(&context_gl->c, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)); - context_gl->c.render_offscreen = offscreen; -} - GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) { return GL_COLOR_ATTACHMENT0; @@ -3525,9 +3505,6 @@ static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_ unsigned int rt_mask, mask; unsigned int i;
- if (!context_gl->c.render_offscreen) - return context_generate_rt_mask_from_resource(rts[0]->resource); - rt_mask = ps ? ps->reg_maps.rt_mask : 1; rt_mask &= wined3d_mask_from_size(gl_info->limits.buffers); if (state->blend_state && state->blend_state->dual_source) @@ -3590,50 +3567,40 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); uint32_t rt_mask = find_draw_buffers_mask(context_gl, state); + const struct wined3d_rendertarget_view_gl *view_gl; struct wined3d_rendertarget_info ds_info = {{0}}; const struct wined3d_fb_state *fb = &state->fb; DWORD color_location = 0; uint32_t *cur_mask;
- if (!context->render_offscreen) - { - wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, NULL, &ds_info, - WINED3D_LOCATION_DRAWABLE, WINED3D_LOCATION_DRAWABLE); - } - else + memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); + for (unsigned int i = 0; i < context_gl->gl_info->limits.buffers; ++i) { - const struct wined3d_rendertarget_view_gl *view_gl; - unsigned int i; - - memset(context_gl->blit_targets, 0, sizeof(context_gl->blit_targets)); - for (i = 0; i < context_gl->gl_info->limits.buffers; ++i) - { - if (!fb->render_targets[i]) - continue; - - view_gl = wined3d_rendertarget_view_gl(fb->render_targets[i]); - context_gl->blit_targets[i].gl_view = view_gl->gl_view; - context_gl->blit_targets[i].resource = view_gl->v.resource; - context_gl->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx; - context_gl->blit_targets[i].layer_count = view_gl->v.layer_count; + if (!fb->render_targets[i]) + continue;
- if (!color_location) - color_location = view_gl->v.resource->draw_binding; - } + view_gl = wined3d_rendertarget_view_gl(fb->render_targets[i]); + context_gl->blit_targets[i].gl_view = view_gl->gl_view; + context_gl->blit_targets[i].resource = view_gl->v.resource; + context_gl->blit_targets[i].sub_resource_idx = view_gl->v.sub_resource_idx; + context_gl->blit_targets[i].layer_count = view_gl->v.layer_count;
- if (fb->depth_stencil) - { - 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; - } + if (!color_location) + color_location = view_gl->v.resource->draw_binding; + }
- wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, - color_location, fb->depth_stencil ? fb->depth_stencil->resource->draw_binding : 0); + if (fb->depth_stencil) + { + 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; }
+ wined3d_context_gl_apply_fbo_state(context_gl, GL_FRAMEBUFFER, context_gl->blit_targets, &ds_info, + color_location, fb->depth_stencil ? fb->depth_stencil->resource->draw_binding : 0); + cur_mask = context_gl->current_fbo ? &context_gl->current_fbo->rt_mask : &context_gl->draw_buffers_mask; if (rt_mask != *cur_mask) { @@ -4236,8 +4203,6 @@ static BOOL context_apply_draw_state(struct wined3d_context *context, FIXME("OpenGL implementation does not support framebuffers with no attachments.\n"); return FALSE; } - - wined3d_context_gl_set_render_offscreen(context_gl, TRUE); }
/* Preload resources before FBO setup. Texture preload in particular may @@ -4447,12 +4412,8 @@ static void wined3d_context_gl_pause_transform_feedback(struct wined3d_context_g static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_gl, struct wined3d_texture *texture, unsigned int sub_resource_idx) { - BOOL old_render_offscreen = context_gl->c.render_offscreen, render_offscreen; - - render_offscreen = wined3d_resource_is_offscreen(&texture->resource); if (context_gl->c.current_rt.texture == texture - && context_gl->c.current_rt.sub_resource_idx == sub_resource_idx - && render_offscreen == old_render_offscreen) + && context_gl->c.current_rt.sub_resource_idx == sub_resource_idx) return;
/* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers @@ -4477,7 +4438,6 @@ static void wined3d_context_gl_setup_target(struct wined3d_context_gl *context_g
context_gl->c.current_rt.texture = texture; context_gl->c.current_rt.sub_resource_idx = sub_resource_idx; - wined3d_context_gl_set_render_offscreen(context_gl, render_offscreen); }
static void wined3d_context_gl_activate(struct wined3d_context_gl *context_gl, @@ -5156,12 +5116,11 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if ((dsv = fb->depth_stencil)) { - /* Note that this depends on the context_acquire() call above to set - * context->render_offscreen properly. We don't currently take the - * Z-compare function into account, but we could skip loading the - * depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note - * that we never copy the stencil data.*/ - DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE; + /* We don't currently take the Z-compare function into account, + * but we could skip loading the depthstencil for D3DCMP_NEVER and + * D3DCMP_ALWAYS as well. + * Also note that we never copy the stencil data. */ + uint32_t location = dsv->resource->draw_binding;
if (wined3d_state_uses_depth_buffer(state)) wined3d_rendertarget_view_load_location(dsv, context, location); @@ -5181,7 +5140,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
if (dsv && (!state->depth_stencil_state || state->depth_stencil_state->writes_ds)) { - DWORD location = context->render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE; + uint32_t location = dsv->resource->draw_binding;
wined3d_rendertarget_view_validate_location(dsv, location); wined3d_rendertarget_view_invalidate_location(dsv, ~location); diff --git a/dlls/wined3d/ffp_gl.c b/dlls/wined3d/ffp_gl.c index 8af67fc12df..85c672972ae 100644 --- a/dlls/wined3d/ffp_gl.c +++ b/dlls/wined3d/ffp_gl.c @@ -360,8 +360,7 @@ static BOOL is_blend_enabled(struct wined3d_context *context, const struct wined /* Disable blending in all cases even without pixel shaders. * With blending on we could face a big performance penalty. * The d3d9 visual test confirms the behavior. */ - if (context->render_offscreen - && !(state->fb.render_targets[index]->format_caps & WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING)) + if (!(state->fb.render_targets[index]->format_caps & WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING)) return FALSE;
return TRUE; @@ -3675,43 +3674,9 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine } }
-static void get_viewports(struct wined3d_context *context, const struct wined3d_state *state, - unsigned int viewport_count, struct wined3d_viewport *viewports) -{ - const struct wined3d_rendertarget_view *depth_stencil = state->fb.depth_stencil; - const struct wined3d_rendertarget_view *target = state->fb.render_targets[0]; - unsigned int width, height, i; - - for (i = 0; i < viewport_count; ++i) - viewports[i] = state->viewports[i]; - - /* Note: GL uses a lower left origin while DirectX uses upper left. This - * is reversed when using offscreen rendering. */ - if (context->render_offscreen) - return; - - if (target) - { - wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height); - } - else if (depth_stencil) - { - height = depth_stencil->height; - } - else - { - FIXME("Could not get the height of render targets.\n"); - return; - } - - for (i = 0; i < viewport_count; ++i) - viewports[i].y = height - (viewports[i].y + viewports[i].height); -} - static void viewport_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS]; float min_z, max_z;
if (gl_info->supported[ARB_VIEWPORT_ARRAY]) @@ -3721,17 +3686,16 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine
unsigned int i, reset_count = 0;
- get_viewports(context, state, state->viewport_count, vp); for (i = 0; i < state->viewport_count; ++i) { - wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z); + wined3d_viewport_get_z_range(&state->viewports[i], &min_z, &max_z); depth_ranges[i * 2] = min_z; depth_ranges[i * 2 + 1] = max_z;
- viewports[i * 4] = vp[i].x; - viewports[i * 4 + 1] = vp[i].y; - viewports[i * 4 + 2] = vp[i].width; - viewports[i * 4 + 3] = vp[i].height; + viewports[i * 4] = state->viewports[i].x; + viewports[i * 4 + 1] = state->viewports[i].y; + viewports[i * 4 + 2] = state->viewports[i].width; + viewports[i * 4 + 3] = state->viewports[i].height;
/* Don't pass fractionals to GL if we earlier decided not to use * this functionality for two reasons: First, GL might offer us @@ -3765,10 +3729,10 @@ static void viewport_miscpart(struct wined3d_context *context, const struct wine } else { - get_viewports(context, state, 1, vp); - wined3d_viewport_get_z_range(&vp[0], &min_z, &max_z); + wined3d_viewport_get_z_range(&state->viewports[0], &min_z, &max_z); gl_info->gl_ops.gl.p_glDepthRange(min_z, max_z); - gl_info->gl_ops.gl.p_glViewport(vp[0].x, vp[0].y, vp[0].width, vp[0].height); + gl_info->gl_ops.gl.p_glViewport(state->viewports[0].x, state->viewports[0].y, + state->viewports[0].width, state->viewports[0].height); } checkGLcall("setting clip space and viewport"); } @@ -3780,27 +3744,25 @@ static void viewport_miscpart_cc(struct wined3d_context *context, /* See get_projection_matrix() in utils.c for a discussion about those values. */ float pixel_center_offset = context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER ? 0.5f : 0.0f; - struct wined3d_viewport vp[WINED3D_MAX_VIEWPORTS]; GLdouble depth_ranges[2 * WINED3D_MAX_VIEWPORTS]; GLfloat viewports[4 * WINED3D_MAX_VIEWPORTS]; unsigned int i, reset_count = 0; float min_z, max_z;
pixel_center_offset += context->d3d_info->filling_convention_offset / 2.0f; - get_viewports(context, state, state->viewport_count, vp);
- GL_EXTCALL(glClipControl(context->render_offscreen ? GL_UPPER_LEFT : GL_LOWER_LEFT, GL_ZERO_TO_ONE)); + GL_EXTCALL(glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE));
for (i = 0; i < state->viewport_count; ++i) { - wined3d_viewport_get_z_range(&vp[i], &min_z, &max_z); + wined3d_viewport_get_z_range(&state->viewports[i], &min_z, &max_z); depth_ranges[i * 2] = min_z; depth_ranges[i * 2 + 1] = max_z;
- viewports[i * 4] = vp[i].x + pixel_center_offset; - viewports[i * 4 + 1] = vp[i].y + pixel_center_offset; - viewports[i * 4 + 2] = vp[i].width; - viewports[i * 4 + 3] = vp[i].height; + viewports[i * 4] = state->viewports[i].x + pixel_center_offset; + viewports[i * 4 + 1] = state->viewports[i].y + pixel_center_offset; + viewports[i * 4 + 2] = state->viewports[i].width; + viewports[i * 4 + 3] = state->viewports[i].height; }
if (context->viewport_count > state->viewport_count) @@ -3937,21 +3899,12 @@ static void light(struct wined3d_context *context, const struct wined3d_state *s static void scissorrect(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - unsigned int height = 0; const RECT *r;
/* Warning: glScissor uses window coordinates, not viewport coordinates, * so our viewport correction does not apply. Warning2: Even in windowed * mode the coords are relative to the window, not the screen. */
- if (!context->render_offscreen) - { - const struct wined3d_rendertarget_view *target = state->fb.render_targets[0]; - unsigned int width; - - wined3d_rendertarget_view_get_drawable_size(target, context, &width, &height); - } - if (gl_info->supported[ARB_VIEWPORT_ARRAY]) { GLint sr[4 * WINED3D_MAX_VIEWPORTS]; @@ -3962,7 +3915,7 @@ static void scissorrect(struct wined3d_context *context, const struct wined3d_st r = &state->scissor_rects[i];
sr[i * 4] = r->left; - sr[i * 4 + 1] = height ? height - r->top : r->top; + sr[i * 4 + 1] = r->top; sr[i * 4 + 2] = r->right - r->left; sr[i * 4 + 3] = r->bottom - r->top; } @@ -3980,8 +3933,7 @@ static void scissorrect(struct wined3d_context *context, const struct wined3d_st else { r = &state->scissor_rects[0]; - gl_info->gl_ops.gl.p_glScissor(r->left, height ? height - r->top : r->top, - r->right - r->left, r->bottom - r->top); + gl_info->gl_ops.gl.p_glScissor(r->left, r->top, r->right - r->left, r->bottom - r->top); checkGLcall("glScissor"); } } @@ -4030,13 +3982,11 @@ static void rasterizer(struct wined3d_context *context, const struct wined3d_sta { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; const struct wined3d_rasterizer_state *r = state->rasterizer_state; - GLenum mode;
- mode = r && r->desc.front_ccw ? GL_CCW : GL_CW; - if (context->render_offscreen) - mode = (mode == GL_CW) ? GL_CCW : GL_CW; - - gl_info->gl_ops.gl.p_glFrontFace(mode); + /* Rendering without ARB_clip_control requires flipping position manually. + * This also means that all primitives will be backwards, so we need to + * also swap which side is the front face. */ + gl_info->gl_ops.gl.p_glFrontFace(r && r->desc.front_ccw ? GL_CW : GL_CCW); checkGLcall("glFrontFace"); depthbias(context, state); fillmode(r, gl_info); @@ -4078,9 +4028,8 @@ static void psorigin_w(struct wined3d_context *context, const struct wined3d_sta static void psorigin(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; - GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
- GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin)); + GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT)); checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)"); }
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 21006d3cf46..08e7d359bf6 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1923,8 +1923,8 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, const struct wined3d_vec4 correction_params = { /* Position is relative to the framebuffer, not the viewport. */ - context->render_offscreen ? 0.0f : (float)state->fb.render_targets[0]->height, - context->render_offscreen ? 1.0f : -1.0f, + 0.0f, + 1.0f, 0.0f, 0.0f, }; diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index a5dabc1f344..2b78c2df150 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2762,7 +2762,7 @@ void find_ds_compile_args(const struct wined3d_state *state, const struct wined3 : pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output; args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
- args->render_offscreen = context->render_offscreen; + args->render_offscreen = 1;
init_interpolation_compile_args(args->interpolation_mode, args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, context->d3d_info); @@ -3056,7 +3056,7 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 if (d3d_info->emulated_flatshading) args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
- args->y_correction = (shader->reg_maps.vpos && d3d_info->frag_coord_correction) ? !context->render_offscreen : 0; + args->y_correction = 0;
for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 8af50fbbf06..c0695762795 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5658,7 +5658,7 @@ void get_projection_matrix(const struct wined3d_context *context, const struct w ERR("Did not expect to enter this codepath without WINED3D_PIXEL_CENTER_INTEGER.\n");
clip_control = d3d_info->clip_control; - flip = !clip_control && context->render_offscreen; + flip = !clip_control; if (!clip_control) center_offset = 1.0f + d3d_info->filling_convention_offset; else diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 83bc6a95efd..a28255e2d1d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -230,7 +230,6 @@ struct wined3d_d3d_info uint32_t vs_clipping : 1; uint32_t shader_double_precision : 1; uint32_t shader_output_interpolation : 1; - uint32_t frag_coord_correction : 1; uint32_t viewport_array_index_any_shader : 1; uint32_t stencil_export : 1; uint32_t texture_npot : 1; @@ -1957,7 +1956,6 @@ struct wined3d_context DWORD transform_feedback_active : 1; DWORD transform_feedback_paused : 1; DWORD fog_coord : 1; - DWORD render_offscreen : 1; DWORD current : 1; DWORD destroyed : 1; DWORD destroy_delayed : 1; @@ -1965,7 +1963,7 @@ struct wined3d_context DWORD update_primitive_type : 1; DWORD update_patch_vertex_count : 1; DWORD update_multisample_state : 1; - DWORD padding : 2; + DWORD padding : 3;
DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
@@ -4403,12 +4401,6 @@ static inline void shader_get_position_fixup(const struct wined3d_context *conte } position_fixup[4 * i + 2] = (center_offset + x) / state->viewports[i].width; position_fixup[4 * i + 3] = -(center_offset + y) / state->viewports[i].height; - - if (context->render_offscreen) - { - position_fixup[4 * i + 1] *= -1.0f; - position_fixup[4 * i + 3] *= -1.0f; - } } }
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/glsl_shader.c | 10 ++-------- dlls/wined3d/shader.c | 2 -- dlls/wined3d/wined3d_private.h | 3 +-- 3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 08e7d359bf6..b401a7afffb 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -8517,16 +8517,10 @@ static GLuint shader_glsl_generate_domain_shader(const struct wined3d_context_gl switch (args->tessellator_output_primitive) { case WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW: - if (args->render_offscreen) - shader_addline(buffer, ", ccw"); - else - shader_addline(buffer, ", cw"); + shader_addline(buffer, ", ccw"); break; case WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW: - if (args->render_offscreen) - shader_addline(buffer, ", cw"); - else - shader_addline(buffer, ", ccw"); + shader_addline(buffer, ", cw"); break; case WINED3D_TESSELLATOR_OUTPUT_POINT: shader_addline(buffer, ", point_mode"); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 2b78c2df150..8cdb045c685 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -2762,8 +2762,6 @@ void find_ds_compile_args(const struct wined3d_state *state, const struct wined3 : pixel_shader ? pixel_shader->limits->packed_input : shader->limits->packed_output; args->next_shader_type = geometry_shader ? WINED3D_SHADER_TYPE_GEOMETRY : WINED3D_SHADER_TYPE_PIXEL;
- args->render_offscreen = 1; - init_interpolation_compile_args(args->interpolation_mode, args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL ? pixel_shader : NULL, context->d3d_info);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index a28255e2d1d..1f2b6ff4723 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1531,8 +1531,7 @@ struct ds_compile_args enum wined3d_tessellator_partitioning tessellator_partitioning; unsigned int output_count : 16; unsigned int next_shader_type : 3; - unsigned int render_offscreen : 1; - unsigned int padding : 12; + unsigned int padding : 13; uint32_t interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE]; };
From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/context_gl.c | 1 - dlls/wined3d/glsl_shader.c | 48 ++++++---------------------------- dlls/wined3d/shader.c | 2 -- dlls/wined3d/wined3d_private.h | 4 +-- 4 files changed, 9 insertions(+), 46 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 6f7cf0eb3e3..95225a06172 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3607,7 +3607,6 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat wined3d_context_gl_apply_draw_buffers(context_gl, rt_mask); *cur_mask = rt_mask; } - context->constant_update_mask |= WINED3D_SHADER_CONST_PS_Y_CORR; }
static void wined3d_context_gl_map_stage(struct wined3d_context_gl *context_gl, unsigned int stage, unsigned int unit) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b401a7afffb..d249f14bc8a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -227,7 +227,6 @@ struct glsl_ps_program GLint fog_end_location; GLint fog_scale_location; GLint alpha_test_ref_location; - GLint ycorrection_location; GLint np2_fixup_location; GLint color_key_location; const struct ps_np2fixup_info *np2_fixup_info; @@ -1918,20 +1917,6 @@ static void shader_glsl_load_constants(struct shader_glsl_priv *priv, checkGLcall("bump env uniforms"); }
- if (update_mask & WINED3D_SHADER_CONST_PS_Y_CORR) - { - const struct wined3d_vec4 correction_params = - { - /* Position is relative to the framebuffer, not the viewport. */ - 0.0f, - 1.0f, - 0.0f, - 0.0f, - }; - - GL_EXTCALL(glUniform4fv(prog->ps.ycorrection_location, 1, &correction_params.x)); - } - if (update_mask & WINED3D_SHADER_CONST_PS_NP2_FIXUP) shader_glsl_load_np2fixup_constants(&prog->ps, gl_info, state); if (update_mask & WINED3D_SHADER_CONST_FFP_COLOR_KEY) @@ -4236,9 +4221,6 @@ static void shader_glsl_pow(const struct wined3d_shader_instruction *ins) /* Map the opcode 1-to-1 to the GL code (arg->dst = instruction(src0, src1, ...) */ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) { - const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; - bool y_correction = ins->ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL - ? priv->cur_ps_args->y_correction : false; struct wined3d_string_buffer *buffer = ins->ctx->buffer; struct glsl_src_param src_param; const char *instruction; @@ -4255,9 +4237,9 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_DSX: instruction = "dFdx"; break; case WINED3DSIH_DSX_COARSE: instruction = "dFdxCoarse"; break; case WINED3DSIH_DSX_FINE: instruction = "dFdxFine"; break; - case WINED3DSIH_DSY: instruction = y_correction ? "ycorrection.y * dFdy" : "dFdy"; break; - case WINED3DSIH_DSY_COARSE: instruction = y_correction ? "ycorrection.y * dFdyCoarse" : "dFdyCoarse"; break; - case WINED3DSIH_DSY_FINE: instruction = y_correction ? "ycorrection.y * dFdyFine" : "dFdyFine"; break; + case WINED3DSIH_DSY: instruction = "dFdy"; break; + case WINED3DSIH_DSY_COARSE: instruction = "dFdyCoarse"; break; + case WINED3DSIH_DSY_FINE: instruction = "dFdyFine"; break; case WINED3DSIH_FIRSTBIT_HI: instruction = "findMSB"; break; case WINED3DSIH_FIRSTBIT_LO: instruction = "findLSB"; break; case WINED3DSIH_FIRSTBIT_SHI: instruction = "findMSB"; break; @@ -8019,20 +8001,12 @@ static GLuint shader_glsl_generate_fragment_shader(const struct wined3d_context_ shader_glsl_append_imm_vec(buffer, &wined3d_srgb_const[1].x, 4, gl_info); shader_addline(buffer, ";\n"); } - if (reg_maps->vpos && !gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) - { - ++extra_constants_needed; - shader_addline(buffer, "uniform vec4 ycorrection;\n"); - } if (reg_maps->vpos) { if (gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) { if (context_gl->c.d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER) - shader_addline(buffer, "layout(%spixel_center_integer) in vec4 gl_FragCoord;\n", - args->y_correction ? "origin_upper_left, " : ""); - else if (args->y_correction) - shader_addline(buffer, "layout(origin_upper_left) in vec4 gl_FragCoord;\n"); + shader_addline(buffer, "layout(pixel_center_integer) in vec4 gl_FragCoord;\n"); } shader_addline(buffer, "vec4 vpos;\n"); } @@ -8123,14 +8097,11 @@ static GLuint shader_glsl_generate_fragment_shader(const struct wined3d_context_ * on drivers that returns integer values. */ if (reg_maps->vpos) { - if (gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS]) - shader_addline(buffer, "vpos = gl_FragCoord;\n"); - else if (context_gl->c.d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER) - shader_addline(buffer, - "vpos = floor(vec4(0, ycorrection[0], 0, 0) + gl_FragCoord * vec4(1, ycorrection[1], 1, 1));\n"); + if (!gl_info->supported[ARB_FRAGMENT_COORD_CONVENTIONS] + && (context_gl->c.d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)) + shader_addline(buffer, "vpos = floor(gl_FragCoord);\n"); else - shader_addline(buffer, - "vpos = vec4(0, ycorrection[0], 0, 0) + gl_FragCoord * vec4(1, ycorrection[1], 1, 1);\n"); + shader_addline(buffer, "vpos = gl_FragCoord;\n"); }
if (reg_maps->shader_version.major < 3 || args->vp_mode != WINED3D_VP_MODE_SHADER) @@ -10342,7 +10313,6 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info * ps->alpha_test_ref_location = GL_EXTCALL(glGetUniformLocation(program_id, "alpha_test_ref"));
ps->np2_fixup_location = GL_EXTCALL(glGetUniformLocation(program_id, "ps_samplerNP2Fixup")); - ps->ycorrection_location = GL_EXTCALL(glGetUniformLocation(program_id, "ycorrection")); ps->color_key_location = GL_EXTCALL(glGetUniformLocation(program_id, "color_key"));
string_buffer_release(&priv->string_buffers, name); @@ -10862,8 +10832,6 @@ static void set_glsl_shader_program(const struct wined3d_context_gl *context_gl, entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_I; if (pshader->reg_maps.boolean_constants) entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_B; - if (entry->ps.ycorrection_location != -1) - entry->constant_update_mask |= WINED3D_SHADER_CONST_PS_Y_CORR;
shader_glsl_load_program_resources(context_gl, priv, program_id, pshader); shader_glsl_load_images(gl_info, priv, program_id, &pshader->reg_maps); diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 8cdb045c685..e08e59125b1 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -3054,8 +3054,6 @@ void find_ps_compile_args(const struct wined3d_state *state, const struct wined3 if (d3d_info->emulated_flatshading) args->flatshading = state->render_states[WINED3D_RS_SHADEMODE] == WINED3D_SHADE_FLAT;
- args->y_correction = 0; - for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i) { struct wined3d_rendertarget_view *rtv = state->fb.render_targets[i]; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1f2b6ff4723..05c6c1e42dc 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -523,7 +523,6 @@ enum wined3d_shader_resource_type #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800 -#define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000 @@ -1499,10 +1498,9 @@ struct ps_compile_args DWORD pointsprite : 1; DWORD flatshading : 1; DWORD alpha_test_func : 3; - DWORD y_correction : 1; DWORD rt_alpha_swizzle : 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */ DWORD dual_source_blend : 1; - DWORD padding : 17; + DWORD padding : 18; };
enum fog_src_type
This merge request was approved by Jan Sikorski.