wined3d: Introduce wined3d_texture_get_gl_buffer().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7bf2a34528
commit
b46ef08c9c
|
@ -337,7 +337,7 @@ static inline DWORD context_generate_rt_mask(GLenum buffer)
|
||||||
|
|
||||||
static inline DWORD context_generate_rt_mask_from_surface(const struct wined3d_surface *target)
|
static inline DWORD context_generate_rt_mask_from_surface(const struct wined3d_surface *target)
|
||||||
{
|
{
|
||||||
return (1u << 31) | surface_get_gl_buffer(target);
|
return (1u << 31) | wined3d_texture_get_gl_buffer(target->container);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void context_set_fbo_key_for_surface(const struct wined3d_context *context,
|
static inline void context_set_fbo_key_for_surface(const struct wined3d_context *context,
|
||||||
|
|
|
@ -698,7 +698,7 @@ static void surface_blt_fbo(const struct wined3d_device *device,
|
||||||
if (src_location == WINED3D_LOCATION_DRAWABLE)
|
if (src_location == WINED3D_LOCATION_DRAWABLE)
|
||||||
{
|
{
|
||||||
TRACE("Source surface %p is onscreen.\n", src_surface);
|
TRACE("Source surface %p is onscreen.\n", src_surface);
|
||||||
buffer = surface_get_gl_buffer(src_surface);
|
buffer = wined3d_texture_get_gl_buffer(src_surface->container);
|
||||||
surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
|
surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -715,7 +715,7 @@ static void surface_blt_fbo(const struct wined3d_device *device,
|
||||||
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
||||||
{
|
{
|
||||||
TRACE("Destination surface %p is onscreen.\n", dst_surface);
|
TRACE("Destination surface %p is onscreen.\n", dst_surface);
|
||||||
buffer = surface_get_gl_buffer(dst_surface);
|
buffer = wined3d_texture_get_gl_buffer(dst_surface->container);
|
||||||
surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
|
surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1444,38 +1444,6 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const
|
||||||
checkGLcall("set_compatible_renderbuffer");
|
checkGLcall("set_compatible_renderbuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum surface_get_gl_buffer(const struct wined3d_surface *surface)
|
|
||||||
{
|
|
||||||
const struct wined3d_swapchain *swapchain = surface->container->swapchain;
|
|
||||||
|
|
||||||
TRACE("surface %p.\n", surface);
|
|
||||||
|
|
||||||
if (!swapchain)
|
|
||||||
{
|
|
||||||
ERR("Surface %p is not on a swapchain.\n", surface);
|
|
||||||
return GL_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (swapchain->back_buffers && swapchain->back_buffers[0] == surface->container)
|
|
||||||
{
|
|
||||||
if (swapchain->render_to_fbo)
|
|
||||||
{
|
|
||||||
TRACE("Returning GL_COLOR_ATTACHMENT0\n");
|
|
||||||
return GL_COLOR_ATTACHMENT0;
|
|
||||||
}
|
|
||||||
TRACE("Returning GL_BACK\n");
|
|
||||||
return GL_BACK;
|
|
||||||
}
|
|
||||||
else if (surface->container == swapchain->front_buffer)
|
|
||||||
{
|
|
||||||
TRACE("Returning GL_FRONT\n");
|
|
||||||
return GL_FRONT;
|
|
||||||
}
|
|
||||||
|
|
||||||
FIXME("Higher back buffer, returning GL_BACK\n");
|
|
||||||
return GL_BACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Context activation is done by the caller. */
|
/* Context activation is done by the caller. */
|
||||||
void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb)
|
void surface_load(struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb)
|
||||||
{
|
{
|
||||||
|
@ -1913,7 +1881,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Onscreen surfaces are always part of a swapchain */
|
/* Onscreen surfaces are always part of a swapchain */
|
||||||
GLenum buffer = surface_get_gl_buffer(surface);
|
GLenum buffer = wined3d_texture_get_gl_buffer(texture);
|
||||||
TRACE("Mapping %#x buffer.\n", buffer);
|
TRACE("Mapping %#x buffer.\n", buffer);
|
||||||
gl_info->gl_ops.gl.p_glReadBuffer(buffer);
|
gl_info->gl_ops.gl.p_glReadBuffer(buffer);
|
||||||
checkGLcall("glReadBuffer");
|
checkGLcall("glReadBuffer");
|
||||||
|
@ -2016,7 +1984,7 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb, struct
|
||||||
if (wined3d_resource_is_offscreen(&texture->resource))
|
if (wined3d_resource_is_offscreen(&texture->resource))
|
||||||
gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context));
|
gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context));
|
||||||
else
|
else
|
||||||
gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(surface));
|
gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(texture));
|
||||||
checkGLcall("glReadBuffer");
|
checkGLcall("glReadBuffer");
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glCopyTexSubImage2D(surface->texture_target, surface->texture_level,
|
gl_info->gl_ops.gl.p_glCopyTexSubImage2D(surface->texture_target, surface->texture_level,
|
||||||
|
@ -2127,7 +2095,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(src_surface));
|
gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
|
||||||
}
|
}
|
||||||
checkGLcall("glReadBuffer");
|
checkGLcall("glReadBuffer");
|
||||||
|
|
||||||
|
@ -2291,7 +2259,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gl_info->gl_ops.gl.p_glReadBuffer(surface_get_gl_buffer(src_surface));
|
gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Only back up the part that will be overwritten */
|
/* TODO: Only back up the part that will be overwritten */
|
||||||
|
|
|
@ -37,6 +37,38 @@ BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct
|
||||||
&& !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
|
&& !(texture->flags & (WINED3D_TEXTURE_PIN_SYSMEM | WINED3D_TEXTURE_COND_NP2_EMULATED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
|
||||||
|
{
|
||||||
|
const struct wined3d_swapchain *swapchain = texture->swapchain;
|
||||||
|
|
||||||
|
TRACE("texture %p.\n", texture);
|
||||||
|
|
||||||
|
if (!swapchain)
|
||||||
|
{
|
||||||
|
ERR("Texture %p is not part of a swapchain.\n", texture);
|
||||||
|
return GL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swapchain->back_buffers && swapchain->back_buffers[0] == texture)
|
||||||
|
{
|
||||||
|
if (swapchain->render_to_fbo)
|
||||||
|
{
|
||||||
|
TRACE("Returning GL_COLOR_ATTACHMENT0.\n");
|
||||||
|
return GL_COLOR_ATTACHMENT0;
|
||||||
|
}
|
||||||
|
TRACE("Returning GL_BACK.\n");
|
||||||
|
return GL_BACK;
|
||||||
|
}
|
||||||
|
else if (texture == swapchain->front_buffer)
|
||||||
|
{
|
||||||
|
TRACE("Returning GL_FRONT.\n");
|
||||||
|
return GL_FRONT;
|
||||||
|
}
|
||||||
|
|
||||||
|
FIXME("Higher back buffer, returning GL_BACK.\n");
|
||||||
|
return GL_BACK;
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
|
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops,
|
||||||
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
|
UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags,
|
||||||
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
|
struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops,
|
||||||
|
|
|
@ -2453,6 +2453,7 @@ void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
|
||||||
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
|
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
|
||||||
BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
|
BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
|
||||||
unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
|
unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
|
||||||
|
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
|
||||||
struct wined3d_resource *wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
|
struct wined3d_resource *wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
|
||||||
UINT sub_resource_idx) DECLSPEC_HIDDEN;
|
UINT sub_resource_idx) DECLSPEC_HIDDEN;
|
||||||
void wined3d_texture_load(struct wined3d_texture *texture,
|
void wined3d_texture_load(struct wined3d_texture *texture,
|
||||||
|
@ -2605,7 +2606,6 @@ void wined3d_surface_cleanup(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
|
||||||
HRESULT surface_color_fill(struct wined3d_surface *s,
|
HRESULT surface_color_fill(struct wined3d_surface *s,
|
||||||
const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN;
|
const RECT *rect, const struct wined3d_color *color) DECLSPEC_HIDDEN;
|
||||||
HRESULT surface_create_dib_section(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
|
HRESULT surface_create_dib_section(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
|
||||||
GLenum surface_get_gl_buffer(const struct wined3d_surface *surface) DECLSPEC_HIDDEN;
|
|
||||||
void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context,
|
void surface_get_drawable_size(const struct wined3d_surface *surface, const struct wined3d_context *context,
|
||||||
unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
|
unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
|
||||||
HRESULT wined3d_surface_init(struct wined3d_surface *surface,
|
HRESULT wined3d_surface_init(struct wined3d_surface *surface,
|
||||||
|
|
Loading…
Reference in New Issue