From: Elizabeth Figura zfigura@codeweavers.com
The GLSL blitter covers a superset of the same functionality. --- dlls/wined3d/context_gl.c | 143 ------------------------ dlls/wined3d/texture.c | 226 +------------------------------------- dlls/wined3d/wined3d_gl.h | 5 - 3 files changed, 6 insertions(+), 368 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index d066e7293a6..0692f957cb9 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -3261,107 +3261,6 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl, checkGLcall("blit state application"); }
-static void wined3d_context_gl_apply_blit_projection(const struct wined3d_context_gl *context_gl, - unsigned int w, unsigned int h) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const GLdouble projection[] = - { - 2.0 / w, 0.0, 0.0, 0.0, - 0.0, 2.0 / h, 0.0, 0.0, - 0.0, 0.0, 2.0, 0.0, - -1.0, -1.0, -1.0, 1.0, - }; - - gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION); - gl_info->gl_ops.gl.p_glLoadMatrixd(projection); -} - -/* Setup OpenGL states for fixed-function blitting. */ -/* Context activation is done by the caller. */ -void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl, - const struct wined3d_device *device) -{ - struct wined3d_context *context = &context_gl->c; - const struct wined3d_gl_info *gl_info; - unsigned int i, sampler; - - gl_info = context_gl->gl_info; - if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) - ERR("Applying fixed-function state without legacy context support.\n"); - - if (context->last_was_ffp_blit) - { - SIZE rt_size; - - wined3d_context_gl_get_rt_size(context_gl, &rt_size); - if (context_gl->blit_size.cx != rt_size.cx || context_gl->blit_size.cy != rt_size.cy) - wined3d_context_gl_apply_blit_projection(context_gl, rt_size.cx, rt_size.cy); - wined3d_context_gl_apply_blit_state(context_gl, device); - - checkGLcall("ffp blit state application"); - return; - } - context->last_was_ffp_blit = TRUE; - - wined3d_context_gl_apply_blit_state(context_gl, device); - - /* Disable all textures. The caller can then bind a texture it wants to blit - * from. */ - for (i = gl_info->limits.ffp_textures - 1; i > 0 ; --i) - { - wined3d_context_gl_active_texture(context_gl, gl_info, i); - - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - - gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - sampler = context_gl->rev_tex_unit_map[i]; - if (sampler != WINED3D_UNMAPPED_STAGE) - { - if (sampler < WINED3D_MAX_FFP_TEXTURES) - context_invalidate_state(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)); - } - } - - wined3d_context_gl_active_texture(context_gl, gl_info, 0); - - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - - gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) - gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.0f); - - gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE); - gl_info->gl_ops.gl.p_glLoadIdentity(); - - /* Setup transforms. */ - gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); - gl_info->gl_ops.gl.p_glLoadIdentity(); - context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))); - wined3d_context_gl_apply_blit_projection(context_gl, context_gl->blit_size.cx, context_gl->blit_size.cy); - context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); - - /* Other misc states. */ - gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_LIGHTING)); - gl_info->p_glDisableWINE(GL_FOG); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FOGENABLE)); - - if (gl_info->supported[EXT_SECONDARY_COLOR]) - { - gl_info->gl_ops.gl.p_glDisable(GL_COLOR_SUM_EXT); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SPECULARENABLE)); - } - checkGLcall("ffp blit state application"); -} - static BOOL have_framebuffer_attachment(unsigned int rt_count, struct wined3d_rendertarget_view * const *rts, const struct wined3d_rendertarget_view *ds) { @@ -5959,45 +5858,3 @@ void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1); wined3d_context_gl_bind_texture(context_gl, info.bind_target, 0); } - -/* Context activation is done by the caller. */ -void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl, - struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, - const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - struct wined3d_blt_info info; - unsigned int level; - - texture2d_get_blt_info(texture_gl, sub_resource_idx, src_rect, &info); - - gl_info->gl_ops.gl.p_glEnable(info.bind_target); - checkGLcall("glEnable(bind_target)"); - - level = sub_resource_idx % texture_gl->t.level_count; - wined3d_context_gl_bind_texture(context_gl, info.bind_target, texture_gl->texture_rgb.name); - apply_texture_blit_state(gl_info, &texture_gl->texture_rgb, info.bind_target, level, filter); - gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, level); - gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - checkGLcall("glTexEnvi"); - - wined3d_context_gl_pause_transform_feedback(context_gl, FALSE); - - /* Draw a quad. */ - gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP); - gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[0].x); - gl_info->gl_ops.gl.p_glVertex2i(dst_rect->left, dst_rect->top); - - gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[1].x); - gl_info->gl_ops.gl.p_glVertex2i(dst_rect->right, dst_rect->top); - - gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[2].x); - gl_info->gl_ops.gl.p_glVertex2i(dst_rect->left, dst_rect->bottom); - - gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[3].x); - gl_info->gl_ops.gl.p_glVertex2i(dst_rect->right, dst_rect->bottom); - gl_info->gl_ops.gl.p_glEnd(); - - gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1); - wined3d_context_gl_bind_texture(context_gl, info.bind_target, 0); -} diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 49832f9fabf..86e4b603663 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -5612,91 +5612,6 @@ static void ffp_blitter_destroy(struct wined3d_blitter *blitter, struct wined3d_ free(blitter); }
-static bool ffp_blit_supported(enum wined3d_blit_op blit_op, const struct wined3d_context *context, - const struct wined3d_resource *src_resource, DWORD src_location, - const struct wined3d_resource *dst_resource, DWORD dst_location) -{ - const struct wined3d_format *src_format = src_resource->format; - const struct wined3d_format *dst_format = dst_resource->format; - bool decompress; - - if (src_resource->type != WINED3D_RTYPE_TEXTURE_2D) - return false; - - decompress = (src_format->attrs & WINED3D_FORMAT_ATTR_COMPRESSED) - && !(dst_format->attrs & WINED3D_FORMAT_ATTR_COMPRESSED); - if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU)) - { - TRACE("Source or destination resource is not GPU accessible.\n"); - return false; - } - - if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id) - { - if (dst_format->depth_size || dst_format->stencil_size) - blit_op = WINED3D_BLIT_OP_DEPTH_BLIT; - else - blit_op = WINED3D_BLIT_OP_COLOR_BLIT; - } - - switch (blit_op) - { - case WINED3D_BLIT_OP_COLOR_BLIT_CKEY: - if (context->d3d_info->ffp_fragment_caps.color_key) - { - TRACE("Colour keying requires converted textures.\n"); - return false; - } - case WINED3D_BLIT_OP_COLOR_BLIT: - case WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST: - if (!wined3d_context_gl_const(context)->gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) - return false; - - if (TRACE_ON(d3d)) - { - TRACE("Checking support for fixup:\n"); - dump_color_fixup_desc(src_format->color_fixup); - } - - /* We only support identity conversions. */ - if (!is_identity_fixup(src_format->color_fixup) - || !is_identity_fixup(dst_format->color_fixup)) - { - if (dst_format->id == src_format->id && dst_location == WINED3D_LOCATION_DRAWABLE) - { - if (context->device->shader_backend == &none_shader_backend) - WARN("Claiming fixup support because of no shader backend.\n"); - return true; - } - else - { - TRACE("Fixups are not supported.\n"); - return false; - } - } - - if (!(dst_resource->bind_flags & WINED3D_BIND_RENDER_TARGET)) - { - if (dst_format->id == src_format->id && dst_location == WINED3D_LOCATION_DRAWABLE) - { - if (context->device->shader_backend == &none_shader_backend) - WARN("Claiming !render_target support because of no shader backend.\n"); - return true; - } - else - { - TRACE("Can only blit to render targets.\n"); - return false; - } - } - return true; - - default: - TRACE("Unsupported blit operation %#x.\n", blit_op); - return false; - } -} - static bool is_full_clear(const struct wined3d_rendertarget_view *rtv, const RECT *draw_rect, const RECT *clear_rect) { unsigned int height = rtv->height; @@ -6057,146 +5972,17 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter, const struct wined3d_format *resolve_format) { - struct wined3d_texture_gl *src_texture_gl = wined3d_texture_gl(src_texture); - struct wined3d_context_gl *context_gl = wined3d_context_gl(context); - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - struct wined3d_resource *src_resource, *dst_resource; - struct wined3d_texture *staging_texture = NULL; - struct wined3d_color_key old_blt_key; - struct wined3d_device *device; struct wined3d_blitter *next; - DWORD old_colour_key_flags; - RECT r; - - src_resource = &src_texture->resource; - dst_resource = &dst_texture->resource; - device = dst_resource->device; - - if (!ffp_blit_supported(op, context, src_resource, src_location, dst_resource, dst_location)) - { - if ((next = blitter->next)) - return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location, - src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, colour_key, filter, - resolve_format); - } - - TRACE("Blt from texture %p, %u to rendertarget %p, %u.\n", - src_texture, src_sub_resource_idx, dst_texture, dst_sub_resource_idx); - - old_blt_key = src_texture->async.src_blt_color_key; - old_colour_key_flags = src_texture->async.color_key_flags; - wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT, colour_key); - - if (!(src_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU)) - { - struct wined3d_resource_desc desc; - struct wined3d_box upload_box; - unsigned int src_level; - HRESULT hr; - - TRACE("Source texture is not GPU accessible, creating a staging texture.\n"); - - src_level = src_sub_resource_idx % src_texture->level_count; - desc.resource_type = WINED3D_RTYPE_TEXTURE_2D; - desc.format = src_texture->resource.format->id; - desc.multisample_type = src_texture->resource.multisample_type; - desc.multisample_quality = src_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_CS; - desc.bind_flags = 0; - desc.access = WINED3D_RESOURCE_ACCESS_GPU; - desc.width = wined3d_texture_get_level_width(src_texture, src_level); - desc.height = wined3d_texture_get_level_height(src_texture, src_level); - desc.depth = 1; - desc.size = 0; - - if (FAILED(hr = wined3d_texture_create(device, &desc, 1, 1, 0, - NULL, NULL, &wined3d_null_parent_ops, &staging_texture))) - { - ERR("Failed to create staging texture, hr %#lx.\n", hr); - return dst_location; - } - - wined3d_box_set(&upload_box, 0, 0, desc.width, desc.height, 0, desc.depth); - wined3d_texture_upload_from_texture(staging_texture, 0, 0, 0, 0, - src_texture, src_sub_resource_idx, &upload_box); - - src_texture = staging_texture; - src_texture_gl = wined3d_texture_gl(src_texture); - src_sub_resource_idx = 0; - } - else - { - /* Make sure the surface is up-to-date. This should probably use - * surface_load_location() and worry about the destination surface - * too, unless we're overwriting it completely. */ - wined3d_texture_load(src_texture, context, FALSE); - } - - if (wined3d_texture_is_full_rect(dst_texture, dst_sub_resource_idx % dst_texture->level_count, dst_rect)) - wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, dst_location); - else - wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location);
- context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location); - wined3d_context_gl_apply_ffp_blit_state(context_gl, device); - - if (dst_location == WINED3D_LOCATION_DRAWABLE) - { - r = *dst_rect; - wined3d_texture_translate_drawable_coords(dst_texture, context_gl->window, &r); - dst_rect = &r; - } - - gl_info->gl_ops.gl.p_glEnable(src_texture_gl->target); - checkGLcall("glEnable(target)"); - - if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST || colour_key) - { - gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST); - checkGLcall("glEnable(GL_ALPHA_TEST)"); - } - - if (colour_key) - { - /* For P8 surfaces, the alpha component contains the palette index. - * Which means that the colourkey is one of the palette entries. In - * other cases pixels that should be masked away have alpha set to 0. */ - if (src_texture->resource.format->id == WINED3DFMT_P8_UINT) - gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, - (float)src_texture->async.src_blt_color_key.color_space_low_value / 255.0f); - else - gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, 0.0f); - checkGLcall("glAlphaFunc"); - } - - wined3d_context_gl_draw_textured_quad(context_gl, src_texture_gl, - src_sub_resource_idx, src_rect, dst_rect, filter); - - if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST || colour_key) - { - gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); - checkGLcall("glDisable(GL_ALPHA_TEST)"); - } - - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable(GL_TEXTURE_2D)"); - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + if (!(next = blitter->next)) { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); + ERR("No blitter to handle blit op %#x.\n", op); + return dst_location; }
- if (dst_texture->swapchain && dst_texture->swapchain->front_buffer == dst_texture) - gl_info->gl_ops.gl.p_glFlush(); - - /* Restore the colour key parameters */ - wined3d_texture_set_color_key(src_texture, WINED3D_CKEY_SRC_BLT, - (old_colour_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL); - - if (staging_texture) - wined3d_texture_decref(staging_texture); - - return dst_location; + return next->ops->blitter_blit(next, op, context, src_texture, src_sub_resource_idx, src_location, + src_rect, dst_texture, dst_sub_resource_idx, dst_location, dst_rect, colour_key, filter, + resolve_format); }
static const struct wined3d_blitter_ops ffp_blitter_ops = diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 49e68d09b3a..52d3b01b8cd 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -736,8 +736,6 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, void wined3d_context_gl_apply_fbo_state_explicit(struct wined3d_context_gl *context_gl, GLenum target, struct wined3d_resource *rt, unsigned int rt_sub_resource_idx, struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, uint32_t location); -void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl, - const struct wined3d_device *device); void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name); void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl); void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name); @@ -750,9 +748,6 @@ void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter); -void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl, - struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx, - const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter); void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask); void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl); void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl *context_gl,