ReactOS 0.4.16-dev-319-g6cf4263
surface.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for surface.c:

Go to the source code of this file.

Classes

struct  blt_info
 
struct  float_rect
 
struct  d3dfmt_converter_desc
 

Macros

#define STRETCH_ROW(type)
 
#define COPY_COLORKEY_FX(type)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
static void cube_coords_float (const RECT *r, UINT w, UINT h, struct float_rect *f)
 
static void texture2d_get_blt_info (const struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *rect, struct blt_info *info)
 
void draw_textured_quad (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
 
static void get_color_masks (const struct wined3d_format *format, DWORD *masks)
 
static BOOL texture2d_is_full_rect (const struct wined3d_texture *texture, unsigned int level, const RECT *r)
 
static void surface_depth_blt_fbo (const struct wined3d_device *device, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect)
 
static BOOL is_multisample_location (const struct wined3d_texture *texture, DWORD location)
 
static void surface_blt_fbo (const struct wined3d_device *device, struct wined3d_context *old_ctx, enum wined3d_texture_filter_type filter, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect_in, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect_in)
 
static BOOL fbo_blitter_supported (enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info, const struct wined3d_resource *src_resource, DWORD src_location, const struct wined3d_resource *dst_resource, DWORD dst_location)
 
static void surface_download_data (struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, DWORD dst_location)
 
void wined3d_surface_upload_data (struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, BOOL srgb, const struct wined3d_const_bo_address *data)
 
static HRESULT surface_upload_from_surface (struct wined3d_surface *dst_surface, const POINT *dst_point, struct wined3d_surface *src_surface, const RECT *src_rect)
 
void surface_set_compatible_renderbuffer (struct wined3d_surface *surface, const struct wined3d_rendertarget_info *rt)
 
static unsigned short float_32_to_16 (const float *in)
 
static void convert_r32_float_r16_float (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_r5g6b5_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_a8r8g8b8_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static BYTE cliptobyte (int x)
 
static void convert_yuy2_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_yuy2_r5g6b5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_a8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_a4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_x4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_a1r5g5b5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt1_x1r5g5b5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt3_a8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt3_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt3_a4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt3_x4r4g4b4 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt5_a8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_dxt5_x8r8g8b8 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_a8r8g8b8_dxt1 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_x8r8g8b8_dxt1 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_a1r5g5b5_dxt1 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_x1r5g5b5_dxt1 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_a8r8g8b8_dxt3 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_x8r8g8b8_dxt3 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_a8r8g8b8_dxt5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static void convert_x8r8g8b8_dxt5 (const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 
static const struct d3dfmt_converter_descfind_converter (enum wined3d_format_id from, enum wined3d_format_id to)
 
static struct wined3d_texturesurface_convert_format (struct wined3d_texture *src_texture, unsigned int sub_resource_idx, const struct wined3d_format *dst_format)
 
static void read_from_framebuffer (struct wined3d_surface *surface, struct wined3d_context *old_ctx, DWORD src_location, DWORD dst_location)
 
void surface_load_fb_texture (struct wined3d_surface *surface, BOOL srgb, struct wined3d_context *old_ctx)
 
static void fb_copy_to_texture_direct (struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface, const RECT *src_rect, const RECT *dst_rect_in, enum wined3d_texture_filter_type filter)
 
static void fb_copy_to_texture_hwstretch (struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface, const RECT *src_rect, const RECT *dst_rect_in, enum wined3d_texture_filter_type filter)
 
void surface_translate_drawable_coords (const struct wined3d_surface *surface, HWND window, RECT *rect)
 
static HRESULT surface_blt_special (struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
 
static BOOL surface_load_sysmem (struct wined3d_surface *surface, struct wined3d_context *context, DWORD dst_location)
 
static BOOL surface_load_drawable (struct wined3d_surface *surface, struct wined3d_context *context)
 
static BOOL surface_load_texture (struct wined3d_surface *surface, struct wined3d_context *context, BOOL srgb)
 
static BOOL surface_load_renderbuffer (struct wined3d_surface *surface, struct wined3d_context *context, DWORD dst_location)
 
BOOL surface_load_location (struct wined3d_surface *surface, struct wined3d_context *context, DWORD location)
 
static void fbo_blitter_destroy (struct wined3d_blitter *blitter, struct wined3d_context *context)
 
static void fbo_blitter_clear (struct wined3d_blitter *blitter, struct wined3d_device *device, unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
 
static DWORD fbo_blitter_blit (struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
 
void wined3d_fbo_blitter_create (struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
 
static void raw_blitter_destroy (struct wined3d_blitter *blitter, struct wined3d_context *context)
 
static void raw_blitter_clear (struct wined3d_blitter *blitter, struct wined3d_device *device, unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
 
static DWORD raw_blitter_blit (struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key, enum wined3d_texture_filter_type filter)
 
void wined3d_raw_blitter_create (struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
 
static void ffp_blitter_destroy (struct wined3d_blitter *blitter, struct wined3d_context *context)
 
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)
 
static BOOL ffp_blitter_use_cpu_clear (struct wined3d_rendertarget_view *view)
 
static void ffp_blitter_clear (struct wined3d_blitter *blitter, struct wined3d_device *device, unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
 
static DWORD ffp_blitter_blit (struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
 
void wined3d_ffp_blitter_create (struct wined3d_blitter **next, const struct wined3d_gl_info *gl_info)
 
static void cpu_blitter_destroy (struct wined3d_blitter *blitter, struct wined3d_context *context)
 
static HRESULT surface_cpu_blt_compressed (const BYTE *src_data, BYTE *dst_data, UINT src_pitch, UINT dst_pitch, UINT update_w, UINT update_h, const struct wined3d_format *format, DWORD flags, const struct wined3d_blt_fx *fx)
 
static HRESULT surface_cpu_blt (struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
 
static void surface_cpu_blt_colour_fill (struct wined3d_rendertarget_view *view, const struct wined3d_box *box, const struct wined3d_color *colour)
 
static void cpu_blitter_clear (struct wined3d_blitter *blitter, struct wined3d_device *device, unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil)
 
static DWORD cpu_blitter_blit (struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter)
 
struct wined3d_blitterwined3d_cpu_blitter_create (void)
 
HRESULT wined3d_surface_blt (struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
 

Variables

static const DWORD surface_simple_locations
 
static const struct d3dfmt_converter_desc converters []
 
static const struct d3dfmt_converter_desc dxtn_converters []
 
static const struct wined3d_blitter_ops fbo_blitter_ops
 
static const struct wined3d_blitter_ops raw_blitter_ops
 
static const struct wined3d_blitter_ops ffp_blitter_ops
 
static const struct wined3d_blitter_ops cpu_blitter_ops
 

Macro Definition Documentation

◆ COPY_COLORKEY_FX

#define COPY_COLORKEY_FX (   type)
Value:
do { \
const type *s; \
type *d = (type *)dbuf, *dx, tmp; \
for (y = sy = 0; y < dst_height; ++y, sy += yinc) \
{ \
s = (const type *)(sbase + (sy >> 16) * src_map.row_pitch); \
dx = d; \
for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
{ \
tmp = s[sx >> 16]; \
if (((tmp & keymask) < keylow || (tmp & keymask) > keyhigh) \
&& ((dx[0] & destkeymask) >= destkeylow && (dx[0] & destkeymask) <= destkeyhigh)) \
{ \
dx[0] = tmp; \
} \
dx = (type *)(((BYTE *)dx) + dstxinc); \
} \
d = (type *)(((BYTE *)d) + dstyinc); \
} \
} while(0)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define d
Definition: ke_i.h:81
GLint dx
Definition: linetemp.h:97
unsigned char BYTE
Definition: xxhash.c:193

◆ STRETCH_ROW

#define STRETCH_ROW (   type)
Value:
do { \
const type *s = (const type *)sbuf; \
type *d = (type *)dbuf; \
for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
d[x] = s[sx >> 16]; \
} while(0)

Function Documentation

◆ cliptobyte()

static BYTE cliptobyte ( int  x)
inlinestatic

Definition at line 1205 of file surface.c.

1206{
1207 return (BYTE)((x < 0) ? 0 : ((x > 255) ? 255 : x));
1208}

Referenced by convert_yuy2_r5g6b5(), and convert_yuy2_x8r8g8b8().

◆ convert_a1r5g5b5_dxt1()

static void convert_a1r5g5b5_dxt1 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1377 of file surface.c.

1379{
1380 wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
1381}
BOOL wined3d_dxt1_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:389
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
@ WINED3DFMT_B5G5R5A1_UNORM
Definition: wined3d.h:222

◆ convert_a8r8g8b8_dxt1()

static void convert_a8r8g8b8_dxt1 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1365 of file surface.c.

1367{
1368 wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1369}
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223

◆ convert_a8r8g8b8_dxt3()

static void convert_a8r8g8b8_dxt3 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1389 of file surface.c.

1391{
1392 wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1393}
BOOL wined3d_dxt3_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:417

◆ convert_a8r8g8b8_dxt5()

static void convert_a8r8g8b8_dxt5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1401 of file surface.c.

1403{
1404 wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1405}
BOOL wined3d_dxt5_encode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:439

◆ convert_a8r8g8b8_x8r8g8b8()

static void convert_a8r8g8b8_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1186 of file surface.c.

1188{
1189 unsigned int x, y;
1190
1191 TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
1192
1193 for (y = 0; y < h; ++y)
1194 {
1195 const DWORD *src_line = (const DWORD *)(src + y * pitch_in);
1196 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
1197
1198 for (x = 0; x < w; ++x)
1199 {
1200 dst_line[x] = 0xff000000 | (src_line[x] & 0xffffff);
1201 }
1202 }
1203}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TRACE(s)
Definition: solgame.cpp:4

◆ convert_dxt1_a1r5g5b5()

static void convert_dxt1_a1r5g5b5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1317 of file surface.c.

1319{
1320 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5A1_UNORM, w, h);
1321}
BOOL wined3d_dxt1_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:317

◆ convert_dxt1_a4r4g4b4()

static void convert_dxt1_a4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1305 of file surface.c.

1307{
1308 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
1309}
@ WINED3DFMT_B4G4R4A4_UNORM
Definition: wined3d.h:110

◆ convert_dxt1_a8r8g8b8()

static void convert_dxt1_a8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1293 of file surface.c.

1295{
1296 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1297}

◆ convert_dxt1_x1r5g5b5()

static void convert_dxt1_x1r5g5b5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1323 of file surface.c.

1325{
1326 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
1327}
@ WINED3DFMT_B5G5R5X1_UNORM
Definition: wined3d.h:109

◆ convert_dxt1_x4r4g4b4()

static void convert_dxt1_x4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1311 of file surface.c.

1313{
1314 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
1315}
@ WINED3DFMT_B4G4R4X4_UNORM
Definition: wined3d.h:113

◆ convert_dxt1_x8r8g8b8()

static void convert_dxt1_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1299 of file surface.c.

1301{
1302 wined3d_dxt1_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1303}
@ WINED3DFMT_B8G8R8X8_UNORM
Definition: wined3d.h:224

◆ convert_dxt3_a4r4g4b4()

static void convert_dxt3_a4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1341 of file surface.c.

1343{
1344 wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4A4_UNORM, w, h);
1345}
BOOL wined3d_dxt3_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:345

◆ convert_dxt3_a8r8g8b8()

static void convert_dxt3_a8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1329 of file surface.c.

1331{
1332 wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1333}

◆ convert_dxt3_x4r4g4b4()

static void convert_dxt3_x4r4g4b4 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1347 of file surface.c.

1349{
1350 wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B4G4R4X4_UNORM, w, h);
1351}

◆ convert_dxt3_x8r8g8b8()

static void convert_dxt3_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1335 of file surface.c.

1337{
1338 wined3d_dxt3_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1339}

◆ convert_dxt5_a8r8g8b8()

static void convert_dxt5_a8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1353 of file surface.c.

1355{
1356 wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8A8_UNORM, w, h);
1357}
BOOL wined3d_dxt5_decode(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, enum wined3d_format_id format, unsigned int w, unsigned int h)
Definition: dxtn.c:369

◆ convert_dxt5_x8r8g8b8()

static void convert_dxt5_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1359 of file surface.c.

1361{
1362 wined3d_dxt5_decode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1363}

◆ convert_r32_float_r16_float()

static void convert_r32_float_r16_float ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1124 of file surface.c.

1126{
1127 unsigned short *dst_s;
1128 const float *src_f;
1129 unsigned int x, y;
1130
1131 TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
1132
1133 for (y = 0; y < h; ++y)
1134 {
1135 src_f = (const float *)(src + y * pitch_in);
1136 dst_s = (unsigned short *) (dst + y * pitch_out);
1137 for (x = 0; x < w; ++x)
1138 {
1139 dst_s[x] = float_32_to_16(src_f + x);
1140 }
1141 }
1142}
unsigned short float_32_to_16(const float in) DECLSPEC_HIDDEN
Definition: math.c:2102

◆ convert_r5g6b5_x8r8g8b8()

static void convert_r5g6b5_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1144 of file surface.c.

1146{
1147 static const unsigned char convert_5to8[] =
1148 {
1149 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
1150 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
1151 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
1152 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
1153 };
1154 static const unsigned char convert_6to8[] =
1155 {
1156 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
1157 0x20, 0x24, 0x28, 0x2d, 0x31, 0x35, 0x39, 0x3d,
1158 0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d,
1159 0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d,
1160 0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
1161 0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
1162 0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd7, 0xdb, 0xdf,
1163 0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff,
1164 };
1165 unsigned int x, y;
1166
1167 TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
1168
1169 for (y = 0; y < h; ++y)
1170 {
1171 const WORD *src_line = (const WORD *)(src + y * pitch_in);
1172 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
1173 for (x = 0; x < w; ++x)
1174 {
1175 WORD pixel = src_line[x];
1176 dst_line[x] = 0xff000000u
1177 | convert_5to8[(pixel & 0xf800u) >> 11] << 16
1178 | convert_6to8[(pixel & 0x07e0u) >> 5] << 8
1179 | convert_5to8[(pixel & 0x001fu)];
1180 }
1181 }
1182}
unsigned short WORD
Definition: ntddk_ex.h:93

◆ convert_x1r5g5b5_dxt1()

static void convert_x1r5g5b5_dxt1 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1383 of file surface.c.

1385{
1386 wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B5G5R5X1_UNORM, w, h);
1387}

◆ convert_x8r8g8b8_dxt1()

static void convert_x8r8g8b8_dxt1 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1371 of file surface.c.

1373{
1374 wined3d_dxt1_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1375}

◆ convert_x8r8g8b8_dxt3()

static void convert_x8r8g8b8_dxt3 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1395 of file surface.c.

1397{
1398 wined3d_dxt3_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1399}

◆ convert_x8r8g8b8_dxt5()

static void convert_x8r8g8b8_dxt5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1407 of file surface.c.

1409{
1410 wined3d_dxt5_encode(src, dst, pitch_in, pitch_out, WINED3DFMT_B8G8R8X8_UNORM, w, h);
1411}

◆ convert_yuy2_r5g6b5()

static void convert_yuy2_r5g6b5 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1252 of file surface.c.

1254{
1255 unsigned int x, y;
1256 int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
1257
1258 TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
1259
1260 for (y = 0; y < h; ++y)
1261 {
1262 const BYTE *src_line = src + y * pitch_in;
1263 WORD *dst_line = (WORD *)(dst + y * pitch_out);
1264 for (x = 0; x < w; ++x)
1265 {
1266 /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
1267 * C = Y - 16; D = U - 128; E = V - 128;
1268 * R = cliptobyte((298 * C + 409 * E + 128) >> 8);
1269 * G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
1270 * B = cliptobyte((298 * C + 516 * D + 128) >> 8);
1271 * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
1272 * U and V are shared between the pixels. */
1273 if (!(x & 1)) /* For every even pixel, read new U and V. */
1274 {
1275 d = (int) src_line[1] - 128;
1276 e = (int) src_line[3] - 128;
1277 r2 = 409 * e + 128;
1278 g2 = - 100 * d - 208 * e + 128;
1279 b2 = 516 * d + 128;
1280 }
1281 c2 = 298 * ((int) src_line[0] - 16);
1282 dst_line[x] = (cliptobyte((c2 + r2) >> 8) >> 3) << 11 /* red */
1283 | (cliptobyte((c2 + g2) >> 8) >> 2) << 5 /* green */
1284 | (cliptobyte((c2 + b2) >> 8) >> 3); /* blue */
1285 /* Scale RGB values to 0..255 range,
1286 * then clip them if still not in range (may be negative),
1287 * then shift them within DWORD if necessary. */
1288 src_line += 2;
1289 }
1290 }
1291}
static BYTE cliptobyte(int x)
Definition: surface.c:1205
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define e
Definition: ke_i.h:82
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static DNS_RECORDW r2
Definition: record.c:38

◆ convert_yuy2_x8r8g8b8()

static void convert_yuy2_x8r8g8b8 ( const BYTE src,
BYTE dst,
DWORD  pitch_in,
DWORD  pitch_out,
unsigned int  w,
unsigned int  h 
)
static

Definition at line 1210 of file surface.c.

1212{
1213 int c2, d, e, r2 = 0, g2 = 0, b2 = 0;
1214 unsigned int x, y;
1215
1216 TRACE("Converting %ux%u pixels, pitches %u %u.\n", w, h, pitch_in, pitch_out);
1217
1218 for (y = 0; y < h; ++y)
1219 {
1220 const BYTE *src_line = src + y * pitch_in;
1221 DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
1222 for (x = 0; x < w; ++x)
1223 {
1224 /* YUV to RGB conversion formulas from http://en.wikipedia.org/wiki/YUV:
1225 * C = Y - 16; D = U - 128; E = V - 128;
1226 * R = cliptobyte((298 * C + 409 * E + 128) >> 8);
1227 * G = cliptobyte((298 * C - 100 * D - 208 * E + 128) >> 8);
1228 * B = cliptobyte((298 * C + 516 * D + 128) >> 8);
1229 * Two adjacent YUY2 pixels are stored as four bytes: Y0 U Y1 V .
1230 * U and V are shared between the pixels. */
1231 if (!(x & 1)) /* For every even pixel, read new U and V. */
1232 {
1233 d = (int) src_line[1] - 128;
1234 e = (int) src_line[3] - 128;
1235 r2 = 409 * e + 128;
1236 g2 = - 100 * d - 208 * e + 128;
1237 b2 = 516 * d + 128;
1238 }
1239 c2 = 298 * ((int) src_line[0] - 16);
1240 dst_line[x] = 0xff000000
1241 | cliptobyte((c2 + r2) >> 8) << 16 /* red */
1242 | cliptobyte((c2 + g2) >> 8) << 8 /* green */
1243 | cliptobyte((c2 + b2) >> 8); /* blue */
1244 /* Scale RGB values to 0..255 range,
1245 * then clip them if still not in range (may be negative),
1246 * then shift them within DWORD if necessary. */
1247 src_line += 2;
1248 }
1249 }
1250}

◆ cpu_blitter_blit()

static DWORD cpu_blitter_blit ( struct wined3d_blitter blitter,
enum wined3d_blit_op  op,
struct wined3d_context context,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key color_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 3934 of file surface.c.

3938{
3939 struct wined3d_box dst_box = {dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, 0, 1};
3940 struct wined3d_box src_box = {src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1};
3941 unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
3942 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
3943 struct wined3d_texture *dst_texture = dst_surface->container;
3944 struct wined3d_texture *src_texture = src_surface->container;
3945 struct wined3d_blt_fx fx;
3946 DWORD flags = 0;
3947
3948 memset(&fx, 0, sizeof(fx));
3949 switch (op)
3950 {
3954 break;
3957 break;
3960 fx.src_color_key = *color_key;
3961 break;
3962 default:
3963 FIXME("Unhandled op %#x.\n", op);
3964 break;
3965 }
3966
3967 if (FAILED(surface_cpu_blt(dst_texture, dst_sub_resource_idx, &dst_box,
3968 src_texture, src_sub_resource_idx, &src_box, flags, &fx, filter)))
3969 ERR("Failed to blit.\n");
3970 wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location);
3971
3972 return dst_location | (dst_texture->sub_resources[dst_sub_resource_idx].locations
3973 & dst_texture->resource.map_binding);
3974}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
UINT op
Definition: effect.c:236
static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: surface.c:3298
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
GLbitfield flags
Definition: glext.h:7161
#define FAILED(hr)
Definition: intsafe.h:51
#define memset(x, y, z)
Definition: compat.h:39
Definition: http.c:7252
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
struct wined3d_texture * container
struct wined3d_resource resource
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
GLfixed fx
Definition: tritemp.h:484
#define WINED3D_BLT_ALPHA_TEST
Definition: wined3d.h:1368
#define WINED3D_BLT_SRC_CKEY_OVERRIDE
Definition: wined3d.h:1363
#define WINED3D_BLT_FX
Definition: wined3d.h:1359
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
@ WINED3D_BLIT_OP_COLOR_BLIT_CKEY
@ WINED3D_BLIT_OP_RAW_BLIT
@ WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
@ WINED3D_BLIT_OP_DEPTH_BLIT
@ WINED3D_BLIT_OP_COLOR_BLIT

◆ cpu_blitter_clear()

static void cpu_blitter_clear ( struct wined3d_blitter blitter,
struct wined3d_device device,
unsigned int  rt_count,
const struct wined3d_fb_state fb,
unsigned int  rect_count,
const RECT clear_rects,
const RECT draw_rect,
DWORD  flags,
const struct wined3d_color colour,
float  depth,
DWORD  stencil 
)
static

Definition at line 3887 of file surface.c.

3890{
3891 struct wined3d_color c = {depth, 0.0f, 0.0f, 0.0f};
3893 struct wined3d_box box;
3894 unsigned int i, j;
3895
3896 if (!rect_count)
3897 {
3898 rect_count = 1;
3899 clear_rects = draw_rect;
3900 }
3901
3902 for (i = 0; i < rect_count; ++i)
3903 {
3904 box.left = max(clear_rects[i].left, draw_rect->left);
3905 box.top = max(clear_rects[i].top, draw_rect->top);
3906 box.right = min(clear_rects[i].right, draw_rect->right);
3907 box.bottom = min(clear_rects[i].bottom, draw_rect->bottom);
3908 box.front = 0;
3909 box.back = 1;
3910
3911 if (box.left >= box.right || box.top >= box.bottom)
3912 continue;
3913
3915 {
3916 for (j = 0; j < rt_count; ++j)
3917 {
3918 if ((view = fb->render_targets[j]))
3920 }
3921 }
3922
3924 {
3925 if ((view->format->depth_size && !(flags & WINED3DCLEAR_ZBUFFER))
3926 || (view->format->stencil_size && !(flags & WINED3DCLEAR_STENCIL)))
3927 FIXME("Clearing %#x on %s.\n", flags, debug_d3dformat(view->format->id));
3928
3930 }
3931 }
3932}
static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view, const struct wined3d_box *box, const struct wined3d_color *colour)
Definition: surface.c:3781
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3980
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
const GLubyte * c
Definition: glext.h:8905
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define min(a, b)
Definition: monoChain.cc:55
Definition: palette.c:468
struct wined3d_rendertarget_view * depth_stencil
struct wined3d_rendertarget_view * render_targets[MAX_RENDER_TARGET_VIEWS]
#define max(a, b)
Definition: svc.c:63
#define WINED3DCLEAR_TARGET
Definition: wined3d.h:997
#define WINED3DCLEAR_STENCIL
Definition: wined3d.h:999
#define WINED3DCLEAR_ZBUFFER
Definition: wined3d.h:998

◆ cpu_blitter_destroy()

static void cpu_blitter_destroy ( struct wined3d_blitter blitter,
struct wined3d_context context 
)
static

Definition at line 3185 of file surface.c.

3186{
3187 struct wined3d_blitter *next;
3188
3189 if ((next = blitter->next))
3190 next->ops->blitter_destroy(next, context);
3191
3192 heap_free(blitter);
3193}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static unsigned __int64 next
Definition: rand_nt.c:6
struct wined3d_blitter * next

◆ cube_coords_float()

static void cube_coords_float ( const RECT r,
UINT  w,
UINT  h,
struct float_rect f 
)
inlinestatic

Definition at line 55 of file surface.c.

56{
57 f->l = ((r->left * 2.0f) / w) - 1.0f;
58 f->t = ((r->top * 2.0f) / h) - 1.0f;
59 f->r = ((r->right * 2.0f) / w) - 1.0f;
60 f->b = ((r->bottom * 2.0f) / h) - 1.0f;
61}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat f
Definition: glext.h:7540

Referenced by texture2d_get_blt_info().

◆ draw_textured_quad()

void draw_textured_quad ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
const RECT src_rect,
const RECT dst_rect,
enum wined3d_texture_filter_type  filter 
)

Definition at line 188 of file surface.c.

191{
192 const struct wined3d_gl_info *gl_info = context->gl_info;
193 struct blt_info info;
194
195 texture2d_get_blt_info(texture, sub_resource_idx, src_rect, &info);
196
197 gl_info->gl_ops.gl.p_glEnable(info.bind_target);
198 checkGLcall("glEnable(bind_target)");
199
200 context_bind_texture(context, info.bind_target, texture->texture_rgb.name);
201
202 /* Filtering for StretchRect */
203 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(filter));
204 checkGLcall("glTexParameteri");
205 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_MIN_FILTER,
207 checkGLcall("glTexParameteri");
208 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
209 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
210 if (context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
211 gl_info->gl_ops.gl.p_glTexParameteri(info.bind_target, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
212 gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
213 checkGLcall("glTexEnvi");
214
215 /* Draw a quad */
216 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
217 gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[0].x);
218 gl_info->gl_ops.gl.p_glVertex2i(dst_rect->left, dst_rect->top);
219
220 gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[1].x);
221 gl_info->gl_ops.gl.p_glVertex2i(dst_rect->right, dst_rect->top);
222
223 gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[2].x);
224 gl_info->gl_ops.gl.p_glVertex2i(dst_rect->left, dst_rect->bottom);
225
226 gl_info->gl_ops.gl.p_glTexCoord3fv(&info.texcoords[3].x);
227 gl_info->gl_ops.gl.p_glVertex2i(dst_rect->right, dst_rect->bottom);
228 gl_info->gl_ops.gl.p_glEnd();
229
230 /* Unbind the texture */
231 context_bind_texture(context, info.bind_target, 0);
232
233 /* We changed the filtering settings on the texture. Inform the
234 * container about this to get the filters reset properly next draw. */
235 texture->texture_rgb.sampler_desc.mag_filter = WINED3D_TEXF_POINT;
236 texture->texture_rgb.sampler_desc.min_filter = WINED3D_TEXF_POINT;
237 texture->texture_rgb.sampler_desc.mip_filter = WINED3D_TEXF_NONE;
238 texture->texture_rgb.sampler_desc.srgb_decode = FALSE;
239}
#define FALSE
Definition: types.h:117
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
static void texture2d_get_blt_info(const struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *rect, struct blt_info *info)
Definition: surface.c:63
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
#define GL_TEXTURE_ENV
Definition: gl.h:642
#define GL_TEXTURE_ENV_MODE
Definition: gl.h:643
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_REPLACE
Definition: gl.h:460
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
struct opengl_funcs gl_ops
@ WINED3D_TEXF_NONE
Definition: wined3d.h:685
@ WINED3D_TEXF_POINT
Definition: wined3d.h:686
@ EXT_TEXTURE_SRGB_DECODE
Definition: wined3d_gl.h:183
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
#define checkGLcall(A)

Referenced by arbfp_blitter_blit(), and ffp_blitter_blit().

◆ fb_copy_to_texture_direct()

static void fb_copy_to_texture_direct ( struct wined3d_surface dst_surface,
struct wined3d_surface src_surface,
const RECT src_rect,
const RECT dst_rect_in,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 1754 of file surface.c.

1756{
1757 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
1758 unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
1759 struct wined3d_texture *src_texture = src_surface->container;
1760 struct wined3d_texture *dst_texture = dst_surface->container;
1761 struct wined3d_device *device = dst_texture->resource.device;
1762 unsigned int src_height, src_level, dst_level;
1763 const struct wined3d_gl_info *gl_info;
1764 float xrel, yrel;
1765 struct wined3d_context *context;
1766 BOOL upsidedown = FALSE;
1767 RECT dst_rect = *dst_rect_in;
1768 GLenum dst_target;
1769
1770 /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
1771 * glCopyTexSubImage is a bit picky about the parameters we pass to it
1772 */
1773 if(dst_rect.top > dst_rect.bottom) {
1774 UINT tmp = dst_rect.bottom;
1775 dst_rect.bottom = dst_rect.top;
1776 dst_rect.top = tmp;
1777 upsidedown = TRUE;
1778 }
1779
1780 context = context_acquire(device, src_texture, src_sub_resource_idx);
1781 gl_info = context->gl_info;
1783 wined3d_texture_load(dst_texture, context, FALSE);
1784
1785 /* Bind the target texture */
1786 context_bind_texture(context, dst_texture->target, dst_texture->texture_rgb.name);
1787 if (wined3d_resource_is_offscreen(&src_texture->resource))
1788 {
1789 TRACE("Reading from an offscreen target\n");
1790 upsidedown = !upsidedown;
1791 gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context));
1792 }
1793 else
1794 {
1795 gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
1796 }
1797 checkGLcall("glReadBuffer");
1798
1799 xrel = (float) (src_rect->right - src_rect->left) / (float) (dst_rect.right - dst_rect.left);
1800 yrel = (float) (src_rect->bottom - src_rect->top) / (float) (dst_rect.bottom - dst_rect.top);
1801
1802 if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
1803 {
1804 FIXME_(d3d_perf)("Doing a pixel by pixel copy from the framebuffer to a texture.\n");
1805
1807 ERR("Texture filtering not supported in direct blit.\n");
1808 }
1810 && ((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
1811 {
1812 ERR("Texture filtering not supported in direct blit\n");
1813 }
1814
1815 src_level = src_sub_resource_idx % src_texture->level_count;
1816 dst_level = dst_sub_resource_idx % dst_texture->level_count;
1817
1818 src_height = wined3d_texture_get_level_height(src_texture, src_level);
1819 dst_target = wined3d_texture_get_sub_resource_target(dst_texture, dst_sub_resource_idx);
1820 if (upsidedown
1821 && !((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
1822 && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
1823 {
1824 /* Upside down copy without stretching is nice, one glCopyTexSubImage call will do. */
1825 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1826 dst_rect.left /*xoffset */, dst_rect.top /* y offset */,
1827 src_rect->left, src_height - src_rect->bottom,
1828 dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
1829 }
1830 else
1831 {
1832 LONG row;
1833 UINT yoffset = src_height - src_rect->top + dst_rect.top - 1;
1834 /* I have to process this row by row to swap the image,
1835 * otherwise it would be upside down, so stretching in y direction
1836 * doesn't cost extra time
1837 *
1838 * However, stretching in x direction can be avoided if not necessary
1839 */
1840 for(row = dst_rect.top; row < dst_rect.bottom; row++) {
1841 if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
1842 {
1843 /* Well, that stuff works, but it's very slow.
1844 * find a better way instead
1845 */
1846 LONG col;
1847
1848 for (col = dst_rect.left; col < dst_rect.right; ++col)
1849 {
1850 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1851 dst_rect.left + col /* x offset */, row /* y offset */,
1852 src_rect->left + col * xrel, yoffset - (int) (row * yrel), 1, 1);
1853 }
1854 }
1855 else
1856 {
1857 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(dst_target, dst_level,
1858 dst_rect.left /* x offset */, row /* y offset */,
1859 src_rect->left, yoffset - (int) (row * yrel), dst_rect.right - dst_rect.left, 1);
1860 }
1861 }
1862 }
1863 checkGLcall("glCopyTexSubImage2D");
1864
1866
1867 /* The texture is now most up to date - If the surface is a render target
1868 * and has a drawable, this path is never entered. */
1869 wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
1870 wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
1871}
#define TRUE
Definition: types.h:120
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context)
Definition: context.c:2954
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
void context_release(struct wined3d_context *context)
Definition: context.c:1571
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
#define FIXME_(x)
Definition: compat.h:77
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int GLenum
Definition: gl.h:150
GLint GLint GLint yoffset
Definition: gl.h:1547
static float(__cdecl *square_half_float)(float x
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
Definition: devices.h:37
const struct wined3d_gl_info * gl_info
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
#define WINED3D_LOCATION_TEXTURE_RGB
#define eps

Referenced by surface_blt_special().

◆ fb_copy_to_texture_hwstretch()

static void fb_copy_to_texture_hwstretch ( struct wined3d_surface dst_surface,
struct wined3d_surface src_surface,
const RECT src_rect,
const RECT dst_rect_in,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 1874 of file surface.c.

1876{
1877 unsigned int src_width, src_height, src_pow2_width, src_pow2_height, src_level;
1878 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
1879 unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
1880 struct wined3d_texture *src_texture = src_surface->container;
1881 struct wined3d_texture *dst_texture = dst_surface->container;
1882 struct wined3d_device *device = dst_texture->resource.device;
1883 GLenum src_target, dst_target, texture_target;
1884 GLuint src, backup = 0;
1885 float left, right, top, bottom; /* Texture coordinates */
1886 const struct wined3d_gl_info *gl_info;
1887 struct wined3d_context *context;
1888 GLenum drawBuffer = GL_BACK;
1889 GLenum offscreen_buffer;
1890 BOOL noBackBufferBackup;
1891 BOOL src_offscreen;
1892 BOOL upsidedown = FALSE;
1893 RECT dst_rect = *dst_rect_in;
1894
1895 TRACE("Using hwstretch blit\n");
1896
1897 src_target = wined3d_texture_get_sub_resource_target(src_texture, src_sub_resource_idx);
1898 dst_target = wined3d_texture_get_sub_resource_target(dst_texture, dst_sub_resource_idx);
1899
1900 /* Activate the Proper context for reading from the source surface, set it up for blitting */
1901 context = context_acquire(device, src_texture, src_sub_resource_idx);
1902 gl_info = context->gl_info;
1904 wined3d_texture_load(dst_texture, context, FALSE);
1905
1906 offscreen_buffer = context_get_offscreen_gl_buffer(context);
1907 src_level = src_sub_resource_idx % src_texture->level_count;
1908 src_width = wined3d_texture_get_level_width(src_texture, src_level);
1909 src_height = wined3d_texture_get_level_height(src_texture, src_level);
1910 src_pow2_width = wined3d_texture_get_level_pow2_width(src_texture, src_level);
1911 src_pow2_height = wined3d_texture_get_level_pow2_height(src_texture, src_level);
1912
1913 src_offscreen = wined3d_resource_is_offscreen(&src_texture->resource);
1914 noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
1915 if (!noBackBufferBackup && !src_texture->texture_rgb.name)
1916 {
1917 /* Get it a description */
1918 wined3d_texture_load(src_texture, context, FALSE);
1919 }
1920
1921 /* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring.
1922 * This way we don't have to wait for the 2nd readback to finish to leave this function.
1923 */
1924 if (context->aux_buffers >= 2)
1925 {
1926 /* Got more than one aux buffer? Use the 2nd aux buffer */
1927 drawBuffer = GL_AUX1;
1928 }
1929 else if ((!src_offscreen || offscreen_buffer == GL_BACK) && context->aux_buffers >= 1)
1930 {
1931 /* Only one aux buffer, but it isn't used (Onscreen rendering, or non-aux orm)? Use it! */
1932 drawBuffer = GL_AUX0;
1933 }
1934
1935 if (noBackBufferBackup)
1936 {
1937 gl_info->gl_ops.gl.p_glGenTextures(1, &backup);
1938 checkGLcall("glGenTextures");
1940 texture_target = GL_TEXTURE_2D;
1941 }
1942 else
1943 {
1944 /* Backup the back buffer and copy the source buffer into a texture to draw an upside down stretched quad. If
1945 * we are reading from the back buffer, the backup can be used as source texture
1946 */
1947 texture_target = src_target;
1948 context_bind_texture(context, texture_target, src_texture->texture_rgb.name);
1949 gl_info->gl_ops.gl.p_glEnable(texture_target);
1950 checkGLcall("glEnable(texture_target)");
1951
1952 /* For now invalidate the texture copy of the back buffer. Drawable and sysmem copy are untouched */
1953 surface_get_sub_resource(src_surface)->locations &= ~WINED3D_LOCATION_TEXTURE_RGB;
1954 }
1955
1956 /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
1957 * glCopyTexSubImage is a bit picky about the parameters we pass to it
1958 */
1959 if(dst_rect.top > dst_rect.bottom) {
1960 UINT tmp = dst_rect.bottom;
1961 dst_rect.bottom = dst_rect.top;
1962 dst_rect.top = tmp;
1963 upsidedown = TRUE;
1964 }
1965
1966 if (src_offscreen)
1967 {
1968 TRACE("Reading from an offscreen target\n");
1969 upsidedown = !upsidedown;
1970 gl_info->gl_ops.gl.p_glReadBuffer(offscreen_buffer);
1971 }
1972 else
1973 {
1974 gl_info->gl_ops.gl.p_glReadBuffer(wined3d_texture_get_gl_buffer(src_texture));
1975 }
1976
1977 /* TODO: Only back up the part that will be overwritten */
1978 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target, 0, 0, 0, 0, 0, src_width, src_height);
1979
1980 checkGLcall("glCopyTexSubImage2D");
1981
1982 /* No issue with overriding these - the sampler is dirty due to blit usage */
1983 gl_info->gl_ops.gl.p_glTexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(filter));
1984 checkGLcall("glTexParameteri");
1985 gl_info->gl_ops.gl.p_glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
1987 checkGLcall("glTexParameteri");
1988
1989 if (!src_texture->swapchain || src_texture == src_texture->swapchain->back_buffers[0])
1990 {
1991 src = backup ? backup : src_texture->texture_rgb.name;
1992 }
1993 else
1994 {
1995 gl_info->gl_ops.gl.p_glReadBuffer(GL_FRONT);
1996 checkGLcall("glReadBuffer(GL_FRONT)");
1997
1998 gl_info->gl_ops.gl.p_glGenTextures(1, &src);
1999 checkGLcall("glGenTextures(1, &src)");
2001
2002 /* TODO: Only copy the part that will be read. Use src_rect->left,
2003 * src_rect->bottom as origin, but with the width watch out for power
2004 * of 2 sizes. */
2005 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_pow2_width,
2006 src_pow2_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
2007 checkGLcall("glTexImage2D");
2008 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, src_width, src_height);
2009
2010 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2011 checkGLcall("glTexParameteri");
2012 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2013 checkGLcall("glTexParameteri");
2014
2015 gl_info->gl_ops.gl.p_glReadBuffer(GL_BACK);
2016 checkGLcall("glReadBuffer(GL_BACK)");
2017
2018 if (texture_target != GL_TEXTURE_2D)
2019 {
2020 gl_info->gl_ops.gl.p_glDisable(texture_target);
2021 gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
2022 texture_target = GL_TEXTURE_2D;
2023 }
2024 }
2025 checkGLcall("glEnd and previous");
2026
2027 left = src_rect->left;
2028 right = src_rect->right;
2029
2030 if (!upsidedown)
2031 {
2032 top = src_height - src_rect->top;
2033 bottom = src_height - src_rect->bottom;
2034 }
2035 else
2036 {
2037 top = src_height - src_rect->bottom;
2038 bottom = src_height - src_rect->top;
2039 }
2040
2041 if (src_texture->flags & WINED3D_TEXTURE_NORMALIZED_COORDS)
2042 {
2043 left /= src_pow2_width;
2044 right /= src_pow2_width;
2045 top /= src_pow2_height;
2046 bottom /= src_pow2_height;
2047 }
2048
2049 /* draw the source texture stretched and upside down. The correct surface is bound already */
2050 gl_info->gl_ops.gl.p_glTexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2051 gl_info->gl_ops.gl.p_glTexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2052
2053 context_set_draw_buffer(context, drawBuffer);
2054 gl_info->gl_ops.gl.p_glReadBuffer(drawBuffer);
2055
2056 gl_info->gl_ops.gl.p_glBegin(GL_QUADS);
2057 /* bottom left */
2058 gl_info->gl_ops.gl.p_glTexCoord2f(left, bottom);
2059 gl_info->gl_ops.gl.p_glVertex2i(0, 0);
2060
2061 /* top left */
2062 gl_info->gl_ops.gl.p_glTexCoord2f(left, top);
2063 gl_info->gl_ops.gl.p_glVertex2i(0, dst_rect.bottom - dst_rect.top);
2064
2065 /* top right */
2066 gl_info->gl_ops.gl.p_glTexCoord2f(right, top);
2067 gl_info->gl_ops.gl.p_glVertex2i(dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
2068
2069 /* bottom right */
2070 gl_info->gl_ops.gl.p_glTexCoord2f(right, bottom);
2071 gl_info->gl_ops.gl.p_glVertex2i(dst_rect.right - dst_rect.left, 0);
2072 gl_info->gl_ops.gl.p_glEnd();
2073 checkGLcall("glEnd and previous");
2074
2075 if (texture_target != dst_target)
2076 {
2077 gl_info->gl_ops.gl.p_glDisable(texture_target);
2078 gl_info->gl_ops.gl.p_glEnable(dst_target);
2079 texture_target = dst_target;
2080 }
2081
2082 /* Now read the stretched and upside down image into the destination texture */
2083 context_bind_texture(context, texture_target, dst_texture->texture_rgb.name);
2084 gl_info->gl_ops.gl.p_glCopyTexSubImage2D(texture_target,
2085 0,
2086 dst_rect.left, dst_rect.top, /* xoffset, yoffset */
2087 0, 0, /* We blitted the image to the origin */
2088 dst_rect.right - dst_rect.left, dst_rect.bottom - dst_rect.top);
2089 checkGLcall("glCopyTexSubImage2D");
2090
2091 if (drawBuffer == GL_BACK)
2092 {
2093 /* Write the back buffer backup back. */
2094 if (backup)
2095 {
2096 if (texture_target != GL_TEXTURE_2D)
2097 {
2098 gl_info->gl_ops.gl.p_glDisable(texture_target);
2099 gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
2100 texture_target = GL_TEXTURE_2D;
2101 }
2103 }
2104 else
2105 {
2106 if (texture_target != src_target)
2107 {
2108 gl_info->gl_ops.gl.p_glDisable(texture_target);
2109 gl_info->gl_ops.gl.p_glEnable(src_target);
2110 texture_target = src_target;
2111 }
2112 context_bind_texture(context, src_target, src_texture->texture_rgb.name);
2113 }
2114
2115 gl_info->gl_ops.gl.p_glBegin(GL_QUADS);
2116 /* top left */
2117 gl_info->gl_ops.gl.p_glTexCoord2f(0.0f, 0.0f);
2118 gl_info->gl_ops.gl.p_glVertex2i(0, src_height);
2119
2120 /* bottom left */
2121 gl_info->gl_ops.gl.p_glTexCoord2f(0.0f, (float)src_height / (float)src_pow2_height);
2122 gl_info->gl_ops.gl.p_glVertex2i(0, 0);
2123
2124 /* bottom right */
2125 gl_info->gl_ops.gl.p_glTexCoord2f((float)src_width / (float)src_pow2_width,
2126 (float)src_height / (float)src_pow2_height);
2127 gl_info->gl_ops.gl.p_glVertex2i(src_width, 0);
2128
2129 /* top right */
2130 gl_info->gl_ops.gl.p_glTexCoord2f((float)src_width / (float)src_pow2_width, 0.0f);
2131 gl_info->gl_ops.gl.p_glVertex2i(src_width, src_height);
2132 gl_info->gl_ops.gl.p_glEnd();
2133 }
2134 gl_info->gl_ops.gl.p_glDisable(texture_target);
2135 checkGLcall("glDisable(texture_target)");
2136
2137 /* Cleanup */
2138 if (src != src_texture->texture_rgb.name && src != backup)
2139 {
2140 gl_info->gl_ops.gl.p_glDeleteTextures(1, &src);
2141 checkGLcall("glDeleteTextures(1, &src)");
2142 }
2143 if (backup)
2144 {
2145 gl_info->gl_ops.gl.p_glDeleteTextures(1, &backup);
2146 checkGLcall("glDeleteTextures(1, &backup)");
2147 }
2148
2150 gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
2151
2153
2154 /* The texture is now most up to date - If the surface is a render target
2155 * and has a drawable, this path is never entered. */
2156 wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
2157 wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
2158}
static long backup()
Definition: maze.c:403
#define NULL
Definition: types.h:112
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
#define GL_AUX1
Definition: gl.h:476
#define GL_QUADS
Definition: gl.h:197
#define GL_BACK
Definition: gl.h:271
unsigned int GLuint
Definition: gl.h:159
#define GL_AUX0
Definition: gl.h:475
#define GL_NEAREST
Definition: gl.h:678
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_RGBA
Definition: gl.h:503
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_FRONT
Definition: gl.h:270
struct wined3d_swapchain * swapchain
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
static struct wined3d_texture_sub_resource * surface_get_sub_resource(struct wined3d_surface *surface)
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)
#define ORM_FBO
#define WINED3D_TEXTURE_NORMALIZED_COORDS

Referenced by surface_blt_special().

◆ fbo_blitter_blit()

static DWORD fbo_blitter_blit ( struct wined3d_blitter blitter,
enum wined3d_blit_op  op,
struct wined3d_context context,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key colour_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 2681 of file surface.c.

2685{
2686 struct wined3d_resource *src_resource = &src_surface->container->resource;
2687 struct wined3d_resource *dst_resource = &dst_surface->container->resource;
2688 struct wined3d_device *device = dst_resource->device;
2689 enum wined3d_blit_op blit_op = op;
2690 struct wined3d_blitter *next;
2691
2692 if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_resource->format->id == src_resource->format->id)
2693 {
2696 else
2698 }
2699
2700 if (!fbo_blitter_supported(blit_op, context->gl_info,
2701 src_resource, src_location, dst_resource, dst_location))
2702 {
2703 if ((next = blitter->next))
2704 return next->ops->blitter_blit(next, op, context, src_surface, src_location,
2705 src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
2706 }
2707
2708 if (blit_op == WINED3D_BLIT_OP_COLOR_BLIT)
2709 {
2710 TRACE("Colour blit.\n");
2711 surface_blt_fbo(device, context, filter, src_surface, src_location,
2712 src_rect, dst_surface, dst_location, dst_rect);
2713 return dst_location;
2714 }
2715
2716 if (blit_op == WINED3D_BLIT_OP_DEPTH_BLIT)
2717 {
2718 TRACE("Depth/stencil blit.\n");
2719 surface_depth_blt_fbo(device, src_surface, src_location, src_rect, dst_surface, dst_location, dst_rect);
2720 return dst_location;
2721 }
2722
2723 ERR("This blitter does not implement blit op %#x.\n", blit_op);
2724 return dst_location;
2725}
static BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info, const struct wined3d_resource *src_resource, DWORD src_location, const struct wined3d_resource *dst_resource, DWORD dst_location)
Definition: surface.c:502
static void surface_blt_fbo(const struct wined3d_device *device, struct wined3d_context *old_ctx, enum wined3d_texture_filter_type filter, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect_in, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect_in)
Definition: surface.c:371
static void surface_depth_blt_fbo(const struct wined3d_device *device, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect)
Definition: surface.c:262
unsigned int format_flags
struct wined3d_device * device
const struct wined3d_format * format
#define WINED3DFMT_FLAG_STENCIL
#define WINED3DFMT_FLAG_DEPTH
wined3d_blit_op

◆ fbo_blitter_clear()

static void fbo_blitter_clear ( struct wined3d_blitter blitter,
struct wined3d_device device,
unsigned int  rt_count,
const struct wined3d_fb_state fb,
unsigned int  rect_count,
const RECT clear_rects,
const RECT draw_rect,
DWORD  flags,
const struct wined3d_color colour,
float  depth,
DWORD  stencil 
)
static

Definition at line 2670 of file surface.c.

2673{
2674 struct wined3d_blitter *next;
2675
2676 if ((next = blitter->next))
2677 next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
2678 clear_rects, draw_rect, flags, colour, depth, stencil);
2679}
GLint GLfloat GLint stencil
Definition: glext.h:6260

◆ fbo_blitter_destroy()

static void fbo_blitter_destroy ( struct wined3d_blitter blitter,
struct wined3d_context context 
)
static

Definition at line 2660 of file surface.c.

2661{
2662 struct wined3d_blitter *next;
2663
2664 if ((next = blitter->next))
2665 next->ops->blitter_destroy(next, context);
2666
2667 heap_free(blitter);
2668}

◆ fbo_blitter_supported()

static BOOL fbo_blitter_supported ( enum wined3d_blit_op  blit_op,
const struct wined3d_gl_info gl_info,
const struct wined3d_resource src_resource,
DWORD  src_location,
const struct wined3d_resource dst_resource,
DWORD  dst_location 
)
static

Definition at line 502 of file surface.c.

505{
506 const struct wined3d_format *src_format = src_resource->format;
507 const struct wined3d_format *dst_format = dst_resource->format;
508
509 if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
510 return FALSE;
511
512 /* Source and/or destination need to be on the GL side */
513 if (!(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
514 return FALSE;
515
516 switch (blit_op)
517 {
520 || (src_resource->usage & WINED3DUSAGE_RENDERTARGET)))
521 return FALSE;
523 || (dst_resource->usage & WINED3DUSAGE_RENDERTARGET)))
524 return FALSE;
525 if ((src_format->id != dst_format->id || dst_location == WINED3D_LOCATION_DRAWABLE)
526 && (!is_identity_fixup(src_format->color_fixup) || !is_identity_fixup(dst_format->color_fixup)))
527 return FALSE;
528 break;
529
532 return FALSE;
534 return FALSE;
535 /* Accept pure swizzle fixups for depth formats. In general we
536 * ignore the stencil component (if present) at the moment and the
537 * swizzle is not relevant with just the depth component. */
538 if (is_complex_fixup(src_format->color_fixup) || is_complex_fixup(dst_format->color_fixup)
539 || is_scaling_fixup(src_format->color_fixup) || is_scaling_fixup(dst_format->color_fixup))
540 return FALSE;
541 break;
542
543 default:
544 return FALSE;
545 }
546
547 return TRUE;
548}
static const char * dst_format
Definition: dib.c:1133
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]
enum wined3d_format_id id
struct color_fixup_desc color_fixup
struct wined3d_fbo_ops fbo_ops
unsigned int access
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
static BOOL is_scaling_fixup(struct color_fixup_desc fixup)
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
#define WINED3DFMT_FLAG_FBO_ATTACHABLE
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
@ WINED3D_GL_RES_TYPE_TEX_2D
#define WINED3D_LOCATION_DRAWABLE

Referenced by fbo_blitter_blit(), and surface_load_texture().

◆ ffp_blit_supported()

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 
)
static

Definition at line 2899 of file surface.c.

2902{
2903 const struct wined3d_format *src_format = src_resource->format;
2904 const struct wined3d_format *dst_format = dst_resource->format;
2905 BOOL decompress;
2906
2907 decompress = src_format && (src_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_COMPRESSED)
2909 if (!decompress && !(src_resource->access & dst_resource->access & WINED3D_RESOURCE_ACCESS_GPU))
2910 {
2911 TRACE("Source or destination resource is not GPU accessible.\n");
2912 return FALSE;
2913 }
2914
2915 if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id)
2916 {
2919 else
2921 }
2922
2923 switch (blit_op)
2924 {
2926 if (context->d3d_info->shader_color_key)
2927 {
2928 TRACE("Color keying requires converted textures.\n");
2929 return FALSE;
2930 }
2933 if (!context->gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
2934 return FALSE;
2935
2936 if (TRACE_ON(d3d))
2937 {
2938 TRACE("Checking support for fixup:\n");
2940 }
2941
2942 /* We only support identity conversions. */
2943 if (!is_identity_fixup(src_format->color_fixup)
2944 || !is_identity_fixup(dst_format->color_fixup))
2945 {
2947 && dst_format->id == src_format->id && dst_location == WINED3D_LOCATION_DRAWABLE)
2948 {
2949 WARN("Claiming fixup support because of ORM_BACKBUFFER.\n");
2950 }
2951 else
2952 {
2953 TRACE("Fixups are not supported.\n");
2954 return FALSE;
2955 }
2956 }
2957
2958 if (!(dst_resource->usage & WINED3DUSAGE_RENDERTARGET))
2959 {
2960 TRACE("Can only blit to render targets.\n");
2961 return FALSE;
2962 }
2963 return TRUE;
2964
2965 default:
2966 TRACE("Unsupported blit operation %#x.\n", blit_op);
2967 return FALSE;
2968 }
2969}
#define WARN(fmt,...)
Definition: precomp.h:61
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4851
#define TRACE_ON(x)
Definition: compat.h:75
@ WINED3D_GL_LEGACY_CONTEXT
Definition: wined3d_gl.h:213
#define ORM_BACKBUFFER
#define WINED3DFMT_FLAG_COMPRESSED

Referenced by ffp_blitter_blit().

◆ ffp_blitter_blit()

static DWORD ffp_blitter_blit ( struct wined3d_blitter blitter,
enum wined3d_blit_op  op,
struct wined3d_context context,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key color_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 3040 of file surface.c.

3044{
3045 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
3046 struct wined3d_texture *src_texture = src_surface->container;
3047 struct wined3d_texture *dst_texture = dst_surface->container;
3048 const struct wined3d_gl_info *gl_info = context->gl_info;
3049 struct wined3d_resource *src_resource, *dst_resource;
3050 struct wined3d_color_key old_blt_key;
3051 struct wined3d_device *device;
3052 struct wined3d_blitter *next;
3053 DWORD old_color_key_flags;
3054 RECT r;
3055
3056 src_resource = &src_texture->resource;
3057 dst_resource = &dst_texture->resource;
3058 device = dst_resource->device;
3059
3060 if (!ffp_blit_supported(op, context, src_resource, src_location, dst_resource, dst_location))
3061 {
3062 if ((next = blitter->next))
3063 return next->ops->blitter_blit(next, op, context, src_surface, src_location,
3064 src_rect, dst_surface, dst_location, dst_rect, color_key, filter);
3065 }
3066
3067 TRACE("Blt from surface %p to rendertarget %p\n", src_surface, dst_surface);
3068
3069 old_blt_key = src_texture->async.src_blt_color_key;
3070 old_color_key_flags = src_texture->async.color_key_flags;
3072
3073 /* Make sure the surface is up-to-date. This should probably use
3074 * surface_load_location() and worry about the destination surface too,
3075 * unless we're overwriting it completely. */
3076 wined3d_texture_load(src_texture, context, FALSE);
3077
3078 /* Activate the destination context, set it up for blitting. */
3080
3081 if (dst_location == WINED3D_LOCATION_DRAWABLE)
3082 {
3083 r = *dst_rect;
3084 surface_translate_drawable_coords(dst_surface, context->win_handle, &r);
3085 dst_rect = &r;
3086 }
3087
3089 {
3090 GLenum buffer;
3091
3092 if (dst_location == WINED3D_LOCATION_DRAWABLE)
3093 {
3094 TRACE("Destination surface %p is onscreen.\n", dst_surface);
3096 }
3097 else
3098 {
3099 TRACE("Destination surface %p is offscreen.\n", dst_surface);
3101 }
3102 context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, dst_surface, NULL, dst_location);
3106 }
3107
3108 gl_info->gl_ops.gl.p_glEnable(src_texture->target);
3109 checkGLcall("glEnable(target)");
3110
3112 {
3113 gl_info->gl_ops.gl.p_glEnable(GL_ALPHA_TEST);
3114 checkGLcall("glEnable(GL_ALPHA_TEST)");
3115 }
3116
3117 if (color_key)
3118 {
3119 /* For P8 surfaces, the alpha component contains the palette index.
3120 * Which means that the colorkey is one of the palette entries. In
3121 * other cases pixels that should be masked away have alpha set to 0. */
3122 if (src_texture->resource.format->id == WINED3DFMT_P8_UINT)
3123 gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL,
3124 (float)src_texture->async.src_blt_color_key.color_space_low_value / 255.0f);
3125 else
3126 gl_info->gl_ops.gl.p_glAlphaFunc(GL_NOTEQUAL, 0.0f);
3127 checkGLcall("glAlphaFunc");
3128 }
3129
3130 draw_textured_quad(src_texture, src_sub_resource_idx, context, src_rect, dst_rect, filter);
3131
3133 {
3134 gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST);
3135 checkGLcall("glDisable(GL_ALPHA_TEST)");
3136 }
3137
3138 /* Leave the OpenGL state valid for blitting. */
3139 gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
3140 checkGLcall("glDisable(GL_TEXTURE_2D)");
3141 if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
3142 {
3143 gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB);
3144 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3145 }
3146 if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
3147 {
3148 gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB);
3149 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3150 }
3151
3153 || (dst_texture->swapchain && dst_texture->swapchain->front_buffer == dst_texture))
3154 gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */
3155
3156 /* Restore the color key parameters */
3158 (old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
3159
3160 return dst_location;
3161}
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target, struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location)
Definition: context.c:802
void draw_textured_quad(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter)
Definition: surface.c:188
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect)
Definition: surface.c:2164
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)
Definition: surface.c:2899
HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key)
Definition: texture.c:1235
#define GL_NOTEQUAL
Definition: gl.h:298
#define GL_ALPHA_TEST
Definition: gl.h:366
GLuint buffer
Definition: glext.h:5915
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
BOOL supported[WINED3D_GL_EXT_COUNT]
struct wined3d_texture::wined3d_texture_async async
#define WINED3D_CKEY_SRC_BLT
Definition: wined3d.h:1336
@ WINED3DFMT_P8_UINT
Definition: wined3d.h:117
@ ARB_TEXTURE_CUBE_MAP
Definition: wined3d_gl.h:113
@ ARB_TEXTURE_RECTANGLE
Definition: wined3d_gl.h:125
#define STATE_FRAMEBUFFER

◆ ffp_blitter_clear()

static void ffp_blitter_clear ( struct wined3d_blitter blitter,
struct wined3d_device device,
unsigned int  rt_count,
const struct wined3d_fb_state fb,
unsigned int  rect_count,
const RECT clear_rects,
const RECT draw_rect,
DWORD  flags,
const struct wined3d_color colour,
float  depth,
DWORD  stencil 
)
static

Definition at line 2991 of file surface.c.

2994{
2996 struct wined3d_blitter *next;
2997 DWORD next_flags = 0;
2998 unsigned int i;
2999
3001 {
3002 for (i = 0; i < rt_count; ++i)
3003 {
3004 if (!(view = fb->render_targets[i]))
3005 continue;
3006
3008 || (!(view->resource->usage & WINED3DUSAGE_RENDERTARGET)
3010 || !(view->format_flags & WINED3DFMT_FLAG_FBO_ATTACHABLE))))
3011 {
3012 next_flags |= WINED3DCLEAR_TARGET;
3013 flags &= ~WINED3DCLEAR_TARGET;
3014 break;
3015 }
3016
3017 /* FIXME: We should reject colour fills on formats with fixups,
3018 * but this would break P8 colour fills for example. */
3019 }
3020 }
3021
3023 && (!view->format->depth_size || (flags & WINED3DCLEAR_ZBUFFER))
3024 && (!view->format->stencil_size || (flags & WINED3DCLEAR_STENCIL))
3026 {
3029 }
3030
3031 if (flags)
3032 device_clear_render_targets(device, rt_count, fb, rect_count,
3033 clear_rects, draw_rect, flags, colour, depth, stencil);
3034
3035 if (next_flags && (next = blitter->next))
3036 next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
3037 clear_rects, draw_rect, next_flags, colour, depth, stencil);
3038}
void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb, UINT rect_count, const RECT *clear_rect, const RECT *draw_rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil)
Definition: device.c:224
static BOOL ffp_blitter_use_cpu_clear(struct wined3d_rendertarget_view *view)
Definition: surface.c:2971

◆ ffp_blitter_destroy()

static void ffp_blitter_destroy ( struct wined3d_blitter blitter,
struct wined3d_context context 
)
static

Definition at line 2889 of file surface.c.

2890{
2891 struct wined3d_blitter *next;
2892
2893 if ((next = blitter->next))
2894 next->ops->blitter_destroy(next, context);
2895
2896 heap_free(blitter);
2897}

◆ ffp_blitter_use_cpu_clear()

static BOOL ffp_blitter_use_cpu_clear ( struct wined3d_rendertarget_view view)
static

Definition at line 2971 of file surface.c.

2972{
2973 struct wined3d_resource *resource;
2974 struct wined3d_texture *texture;
2976
2977 resource = view->resource;
2978 if (resource->type == WINED3D_RTYPE_BUFFER)
2979 return !(resource->access & WINED3D_RESOURCE_ACCESS_GPU);
2980
2982 locations = texture->sub_resources[view->sub_resource_idx].locations;
2983 if (locations & (resource->map_binding | WINED3D_LOCATION_DISCARDED))
2984 return !(resource->access & WINED3D_RESOURCE_ACCESS_GPU)
2985 || (texture->flags & WINED3D_TEXTURE_PIN_SYSMEM);
2986
2987 return !(resource->access & WINED3D_RESOURCE_ACCESS_GPU)
2988 && !(texture->flags & WINED3D_TEXTURE_CONVERTED);
2989}
GLsizei const GLint * locations
Definition: glext.h:10542
#define resource
Definition: kernel32.h:9
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:698
#define WINED3D_TEXTURE_PIN_SYSMEM
#define WINED3D_TEXTURE_CONVERTED
#define WINED3D_LOCATION_DISCARDED
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)

Referenced by ffp_blitter_clear().

◆ find_converter()

static const struct d3dfmt_converter_desc * find_converter ( enum wined3d_format_id  from,
enum wined3d_format_id  to 
)
inlinestatic

Definition at line 1456 of file surface.c.

1458{
1459 unsigned int i;
1460
1461 for (i = 0; i < ARRAY_SIZE(converters); ++i)
1462 {
1463 if (converters[i].from == from && converters[i].to == to)
1464 return &converters[i];
1465 }
1466
1467 for (i = 0; i < (sizeof(dxtn_converters) / sizeof(*dxtn_converters)); ++i)
1468 {
1469 if (dxtn_converters[i].from == from && dxtn_converters[i].to == to)
1471 }
1472
1473 return NULL;
1474}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct d3dfmt_converter_desc converters[]
Definition: surface.c:1419
static const struct d3dfmt_converter_desc dxtn_converters[]
Definition: surface.c:1429
BOOL wined3d_dxtn_supported(void)
Definition: dxtn.c:510
CardRegion * from
Definition: spigame.cpp:19

Referenced by surface_convert_format().

◆ float_32_to_16()

static unsigned short float_32_to_16 ( const float in)
inlinestatic

Definition at line 1062 of file surface.c.

1063{
1064 int exp = 0;
1065 float tmp = fabsf(*in);
1066 unsigned int mantissa;
1067 unsigned short ret;
1068
1069 /* Deal with special numbers */
1070 if (*in == 0.0f)
1071 return 0x0000;
1072 if (isnan(*in))
1073 return 0x7c01;
1074 if (isinf(*in))
1075 return (*in < 0.0f ? 0xfc00 : 0x7c00);
1076
1077 if (tmp < (float)(1u << 10))
1078 {
1079 do
1080 {
1081 tmp = tmp * 2.0f;
1082 exp--;
1083 } while (tmp < (float)(1u << 10));
1084 }
1085 else if (tmp >= (float)(1u << 11))
1086 {
1087 do
1088 {
1089 tmp /= 2.0f;
1090 exp++;
1091 } while (tmp >= (float)(1u << 11));
1092 }
1093
1094 mantissa = (unsigned int)tmp;
1095 if (tmp - mantissa >= 0.5f)
1096 ++mantissa; /* Round to nearest, away from zero. */
1097
1098 exp += 10; /* Normalize the mantissa. */
1099 exp += 15; /* Exponent is encoded with excess 15. */
1100
1101 if (exp > 30) /* too big */
1102 {
1103 ret = 0x7c00; /* INF */
1104 }
1105 else if (exp <= 0)
1106 {
1107 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
1108 while (exp <= 0)
1109 {
1110 mantissa = mantissa >> 1;
1111 ++exp;
1112 }
1113 ret = mantissa & 0x3ff;
1114 }
1115 else
1116 {
1117 ret = (exp << 10) | (mantissa & 0x3ff);
1118 }
1119
1120 ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */
1121 return ret;
1122}
GLuint in
Definition: glext.h:9616
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:179
#define isinf(x)
Definition: mingw_math.h:94
#define isnan(x)
Definition: mingw_math.h:133
DWORD exp
Definition: msg.c:16058
int ret

◆ get_color_masks()

static void get_color_masks ( const struct wined3d_format format,
DWORD masks 
)
static

Definition at line 242 of file surface.c.

243{
244 masks[0] = ((1u << format->red_size) - 1) << format->red_offset;
245 masks[1] = ((1u << format->green_size) - 1) << format->green_offset;
246 masks[2] = ((1u << format->blue_size) - 1) << format->blue_offset;
247}
static const BYTE masks[8]
Definition: dib.c:2760
Definition: format.c:58

Referenced by surface_cpu_blt().

◆ is_multisample_location()

static BOOL is_multisample_location ( const struct wined3d_texture texture,
DWORD  location 
)
static

Definition at line 360 of file surface.c.

361{
363 return TRUE;
365 return FALSE;
367}
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define WINED3D_LOCATION_TEXTURE_SRGB
#define WINED3D_LOCATION_RB_MULTISAMPLE

Referenced by surface_blt_fbo(), and surface_load_sysmem().

◆ raw_blitter_blit()

static DWORD raw_blitter_blit ( struct wined3d_blitter blitter,
enum wined3d_blit_op  op,
struct wined3d_context context,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect,
const struct wined3d_color_key colour_key,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 2781 of file surface.c.

2785{
2786 const struct wined3d_gl_info *gl_info = context->gl_info;
2787 unsigned int src_sub_resource_idx, dst_sub_resource_idx;
2788 unsigned int src_level, src_layer, dst_level, dst_layer;
2789 struct wined3d_texture *src_texture, *dst_texture;
2790 struct wined3d_blitter *next;
2791 GLuint src_name, dst_name;
2793
2794 src_texture = src_surface->container;
2795 dst_texture = dst_surface->container;
2796
2797 /* If we would need to copy from a renderbuffer or drawable, we'd probably
2798 * be better of using the FBO blitter directly, since we'd need to use it
2799 * to copy the resource contents to the texture anyway. */
2801 || (src_texture->resource.format->id == dst_texture->resource.format->id
2804 {
2805 if (!(next = blitter->next))
2806 {
2807 ERR("No blitter to handle blit op %#x.\n", op);
2808 return dst_location;
2809 }
2810
2811 TRACE("Forwarding to blitter %p.\n", next);
2812 return next->ops->blitter_blit(next, op, context, src_surface, src_location,
2813 src_rect, dst_surface, dst_location, dst_rect, colour_key, filter);
2814 }
2815
2816 TRACE("Blit using ARB_copy_image.\n");
2817
2818 src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
2819 src_level = src_sub_resource_idx % src_texture->level_count;
2820 src_layer = src_sub_resource_idx / src_texture->level_count;
2821
2822 dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
2823 dst_level = dst_sub_resource_idx % dst_texture->level_count;
2824 dst_layer = dst_sub_resource_idx / dst_texture->level_count;
2825
2827 if (!location)
2828 location = src_texture->flags & WINED3D_TEXTURE_IS_SRGB
2830 if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, location))
2831 ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(location));
2833
2835 if (!location)
2836 location = dst_texture->flags & WINED3D_TEXTURE_IS_SRGB
2838 if (texture2d_is_full_rect(dst_texture, dst_level, dst_rect))
2839 {
2840 if (!wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, location))
2841 ERR("Failed to prepare the destination sub-resource into %s.\n", wined3d_debug_location(location));
2842 }
2843 else
2844 {
2845 if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, location))
2846 ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(location));
2847 }
2849
2850 GL_EXTCALL(glCopyImageSubData(src_name, src_texture->target, src_level,
2851 src_rect->left, src_rect->top, src_layer, dst_name, dst_texture->target, dst_level,
2852 dst_rect->left, dst_rect->top, dst_layer, src_rect->right - src_rect->left,
2853 src_rect->bottom - src_rect->top, 1));
2854 checkGLcall("copy image data");
2855
2856 wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, location);
2857 wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~location);
2858 if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, dst_location))
2859 ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(dst_location));
2860
2861 return dst_location | location;
2862}
static BOOL texture2d_is_full_rect(const struct wined3d_texture *texture, unsigned int level, const RECT *r)
Definition: surface.c:249
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1605
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6396
#define location(file, line)
Definition: kmtest.h:18
#define GL_EXTCALL(f)
static GLuint wined3d_texture_get_texture_name(const struct wined3d_texture *texture, const struct wined3d_context *context, BOOL srgb)
#define WINED3D_TEXTURE_IS_SRGB

◆ raw_blitter_clear()

static void raw_blitter_clear ( struct wined3d_blitter blitter,
struct wined3d_device device,
unsigned int  rt_count,
const struct wined3d_fb_state fb,
unsigned int  rect_count,
const RECT clear_rects,
const RECT draw_rect,
DWORD  flags,
const struct wined3d_color colour,
float  depth,
DWORD  stencil 
)
static

Definition at line 2763 of file surface.c.

2766{
2767 struct wined3d_blitter *next;
2768
2769 if (!(next = blitter->next))
2770 {
2771 ERR("No blitter to handle clear.\n");
2772 return;
2773 }
2774
2775 TRACE("Forwarding to blitter %p.\n", next);
2776 next->ops->blitter_clear(next, device, rt_count, fb, rect_count,
2777 clear_rects, draw_rect, flags, colour, depth, stencil);
2778}

◆ raw_blitter_destroy()

static void raw_blitter_destroy ( struct wined3d_blitter blitter,
struct wined3d_context context 
)
static

Definition at line 2752 of file surface.c.

2753{
2754 struct wined3d_blitter *next;
2755
2756 if ((next = blitter->next))
2757 next->ops->blitter_destroy(next, context);
2758
2759 heap_free(blitter);
2760}

◆ read_from_framebuffer()

static void read_from_framebuffer ( struct wined3d_surface surface,
struct wined3d_context old_ctx,
DWORD  src_location,
DWORD  dst_location 
)
static

Definition at line 1578 of file surface.c.

1580{
1581 unsigned int sub_resource_idx = surface_get_sub_resource_idx(surface);
1582 struct wined3d_texture *texture = surface->container;
1583 struct wined3d_device *device = texture->resource.device;
1584 struct wined3d_context *context = old_ctx;
1585 struct wined3d_surface *restore_rt = NULL;
1586 const struct wined3d_gl_info *gl_info;
1587 unsigned int row_pitch, slice_pitch;
1588 unsigned int width, height, level;
1589 struct wined3d_bo_address data;
1590 BYTE *row, *top, *bottom;
1591 BOOL src_is_upside_down;
1592 unsigned int i;
1593 BYTE *mem;
1594
1595 wined3d_texture_get_memory(texture, sub_resource_idx, &data, dst_location);
1596
1597 restore_rt = context_get_rt_surface(old_ctx);
1598 if (restore_rt != surface)
1599 context = context_acquire(device, texture, sub_resource_idx);
1600 else
1601 restore_rt = NULL;
1602 gl_info = context->gl_info;
1603
1604 if (src_location != texture->resource.draw_binding)
1605 {
1609 }
1610 else
1611 {
1613 }
1614
1615 /* Select the correct read buffer, and give some debug output.
1616 * There is no need to keep track of the current read buffer or reset it,
1617 * every part of the code that reads sets the read buffer as desired.
1618 */
1619 if (src_location != WINED3D_LOCATION_DRAWABLE || wined3d_resource_is_offscreen(&texture->resource))
1620 {
1621 /* Mapping the primary render target which is not on a swapchain.
1622 * Read from the back buffer. */
1623 TRACE("Mapping offscreen render target.\n");
1624 gl_info->gl_ops.gl.p_glReadBuffer(context_get_offscreen_gl_buffer(context));
1625 src_is_upside_down = TRUE;
1626 }
1627 else
1628 {
1629 /* Onscreen surfaces are always part of a swapchain */
1631 TRACE("Mapping %#x buffer.\n", buffer);
1632 gl_info->gl_ops.gl.p_glReadBuffer(buffer);
1633 src_is_upside_down = FALSE;
1634 }
1635 checkGLcall("glReadBuffer");
1636
1637 if (data.buffer_object)
1638 {
1639 GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data.buffer_object));
1640 checkGLcall("glBindBuffer");
1641 }
1642
1643 level = sub_resource_idx % texture->level_count;
1644 wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch);
1645
1646 /* Setup pixel store pack state -- to glReadPixels into the correct place */
1647 gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / texture->resource.format->byte_count);
1648 checkGLcall("glPixelStorei");
1649
1652 gl_info->gl_ops.gl.p_glReadPixels(0, 0, width, height,
1653 texture->resource.format->glFormat,
1654 texture->resource.format->glType, data.addr);
1655 checkGLcall("glReadPixels");
1656
1657 /* Reset previous pixel store pack state */
1658 gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, 0);
1659 checkGLcall("glPixelStorei");
1660
1661 if (!src_is_upside_down)
1662 {
1663 /* glReadPixels returns the image upside down, and there is no way to
1664 * prevent this. Flip the lines in software. */
1665
1666 if (!(row = heap_alloc(row_pitch)))
1667 goto error;
1668
1669 if (data.buffer_object)
1670 {
1672 checkGLcall("glMapBuffer");
1673 }
1674 else
1675 mem = data.addr;
1676
1677 top = mem;
1678 bottom = mem + row_pitch * (height - 1);
1679 for (i = 0; i < height / 2; i++)
1680 {
1681 memcpy(row, top, row_pitch);
1682 memcpy(top, bottom, row_pitch);
1683 memcpy(bottom, row, row_pitch);
1684 top += row_pitch;
1685 bottom -= row_pitch;
1686 }
1687 heap_free(row);
1688
1689 if (data.buffer_object)
1690 GL_EXTCALL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));
1691 }
1692
1693error:
1694 if (data.buffer_object)
1695 {
1696 GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
1697 checkGLcall("glBindBuffer");
1698 }
1699
1700 if (restore_rt)
1701 context_restore(context, restore_rt);
1702}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
void context_restore(struct wined3d_context *context, struct wined3d_surface *restore)
Definition: context.c:1606
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:285
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1168
GLint level
Definition: gl.h:1546
#define GL_PACK_ROW_LENGTH
Definition: gl.h:628
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476
#define GL_READ_WRITE
Definition: glext.h:343
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: mem.c:349
static struct wined3d_surface * context_get_rt_surface(const struct wined3d_context *context)

Referenced by surface_load_sysmem().

◆ surface_blt_fbo()

static void surface_blt_fbo ( const struct wined3d_device device,
struct wined3d_context old_ctx,
enum wined3d_texture_filter_type  filter,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect_in,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect_in 
)
static

Definition at line 371 of file surface.c.

375{
376 unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
377 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
378 struct wined3d_texture *dst_texture = dst_surface->container;
379 struct wined3d_texture *src_texture = src_surface->container;
380 const struct wined3d_gl_info *gl_info;
381 struct wined3d_context *context = old_ctx;
382 struct wined3d_surface *required_rt, *restore_rt = NULL;
383 RECT src_rect, dst_rect;
384 GLenum gl_filter;
386 int i;
387
388 TRACE("device %p, filter %s,\n", device, debug_d3dtexturefiltertype(filter));
389 TRACE("src_surface %p, src_location %s, src_rect %s,\n",
390 src_surface, wined3d_debug_location(src_location), wine_dbgstr_rect(src_rect_in));
391 TRACE("dst_surface %p, dst_location %s, dst_rect %s.\n",
392 dst_surface, wined3d_debug_location(dst_location), wine_dbgstr_rect(dst_rect_in));
393
394 src_rect = *src_rect_in;
395 dst_rect = *dst_rect_in;
396
397 switch (filter)
398 {
400 gl_filter = GL_LINEAR;
401 break;
402
403 default:
404 FIXME("Unsupported filter mode %s (%#x).\n", debug_d3dtexturefiltertype(filter), filter);
407 gl_filter = GL_NEAREST;
408 break;
409 }
410
411 /* Resolve the source surface first if needed. */
412 if (is_multisample_location(src_texture, src_location)
413 && (src_texture->resource.format->id != dst_texture->resource.format->id
414 || abs(src_rect.bottom - src_rect.top) != abs(dst_rect.bottom - dst_rect.top)
415 || abs(src_rect.right - src_rect.left) != abs(dst_rect.right - dst_rect.left)))
416 src_location = WINED3D_LOCATION_RB_RESOLVED;
417
418 /* Make sure the locations are up-to-date. Loading the destination
419 * surface isn't required if the entire surface is overwritten. (And is
420 * in fact harmful if we're being called by surface_load_location() with
421 * the purpose of loading the destination surface.) */
422 wined3d_texture_load_location(src_texture, src_sub_resource_idx, old_ctx, src_location);
423 if (!texture2d_is_full_rect(dst_texture, dst_sub_resource_idx % dst_texture->level_count, &dst_rect))
424 wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, old_ctx, dst_location);
425 else
426 wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, old_ctx, dst_location);
427
428
429 if (src_location == WINED3D_LOCATION_DRAWABLE) required_rt = src_surface;
430 else if (dst_location == WINED3D_LOCATION_DRAWABLE) required_rt = dst_surface;
431 else required_rt = NULL;
432
433 restore_rt = context_get_rt_surface(old_ctx);
434 if (restore_rt != required_rt)
435 context = context_acquire(device, required_rt ? required_rt->container : NULL,
436 required_rt ? surface_get_sub_resource_idx(required_rt) : 0);
437 else
438 restore_rt = NULL;
439
440 if (!context->valid)
441 {
443 WARN("Invalid context, skipping blit.\n");
444 return;
445 }
446
447 gl_info = context->gl_info;
448
449 if (src_location == WINED3D_LOCATION_DRAWABLE)
450 {
451 TRACE("Source surface %p is onscreen.\n", src_surface);
453 surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
454 }
455 else
456 {
457 TRACE("Source surface %p is offscreen.\n", src_surface);
459 }
460
461 context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, src_surface, NULL, src_location);
462 gl_info->gl_ops.gl.p_glReadBuffer(buffer);
463 checkGLcall("glReadBuffer()");
465
466 if (dst_location == WINED3D_LOCATION_DRAWABLE)
467 {
468 TRACE("Destination surface %p is onscreen.\n", dst_surface);
470 surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
471 }
472 else
473 {
474 TRACE("Destination surface %p is offscreen.\n", dst_surface);
476 }
477
478 context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, dst_surface, NULL, dst_location);
482
483 gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
484 for (i = 0; i < MAX_RENDER_TARGETS; ++i)
486
487 gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
489
490 gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
491 dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, GL_COLOR_BUFFER_BIT, gl_filter);
492 checkGLcall("glBlitFramebuffer()");
493
495 && dst_texture->swapchain->front_buffer == dst_texture))
496 gl_info->gl_ops.gl.p_glFlush();
497
498 if (restore_rt)
499 context_restore(context, restore_rt);
500}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
static BOOL is_multisample_location(const struct wined3d_texture *texture, DWORD location)
Definition: surface.c:360
const char * debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type)
Definition: utils.c:4539
#define abs(i)
Definition: fconv.c:206
#define GL_TRUE
Definition: gl.h:174
#define GL_LINEAR
Definition: gl.h:421
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define GL_SCISSOR_TEST
Definition: gl.h:589
@ WINED3D_RS_SCISSORTESTENABLE
Definition: wined3d.h:358
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:687
static enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
Definition: wined3d.h:400
#define WINED3D_LOCATION_RB_RESOLVED
#define MAX_RENDER_TARGETS
#define STATE_RENDER(a)

Referenced by fbo_blitter_blit(), surface_load_renderbuffer(), and surface_load_texture().

◆ surface_blt_special()

static HRESULT surface_blt_special ( struct wined3d_surface dst_surface,
const RECT dst_rect,
struct wined3d_surface src_surface,
const RECT src_rect,
DWORD  flags,
const struct wined3d_blt_fx fx,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 2187 of file surface.c.

2190{
2191 struct wined3d_texture *dst_texture = dst_surface->container;
2192 struct wined3d_device *device = dst_texture->resource.device;
2193 const struct wined3d_surface *rt = wined3d_rendertarget_view_get_surface(device->fb.render_targets[0]);
2194 struct wined3d_swapchain *src_swapchain, *dst_swapchain;
2195 struct wined3d_texture *src_texture;
2196
2197 TRACE("dst_surface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p, filter %s.\n",
2198 dst_surface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect),
2200
2201 /* Get the swapchain. One of the surfaces has to be a primary surface. */
2202 if (!(dst_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU))
2203 {
2204 WARN("Destination resource is not GPU accessible, rejecting GL blit.\n");
2206 }
2207
2208 dst_swapchain = dst_texture->swapchain;
2209
2210 if (src_surface)
2211 {
2212 src_texture = src_surface->container;
2213 if (!(src_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU))
2214 {
2215 WARN("Source resource is not GPU accessible, rejecting GL blit.\n");
2217 }
2218
2219 src_swapchain = src_texture->swapchain;
2220 }
2221 else
2222 {
2223 src_texture = NULL;
2224 src_swapchain = NULL;
2225 }
2226
2227 /* Early sort out of cases where no render target is used */
2228 if (!dst_swapchain && !src_swapchain && src_surface != rt && dst_surface != rt)
2229 {
2230 TRACE("No surface is render target, not using hardware blit.\n");
2232 }
2233
2234 /* No destination color keying supported */
2236 {
2237 /* Can we support that with glBlendFunc if blitting to the frame buffer? */
2238 TRACE("Destination color key not supported in accelerated Blit, falling back to software\n");
2240 }
2241
2242 if (dst_swapchain && dst_swapchain == src_swapchain)
2243 {
2244 FIXME("Implement hardware blit between two surfaces on the same swapchain\n");
2246 }
2247
2248 if (dst_swapchain && src_swapchain)
2249 {
2250 FIXME("Implement hardware blit between two different swapchains\n");
2252 }
2253
2254 if (dst_swapchain)
2255 {
2256 /* Handled with regular texture -> swapchain blit */
2257 if (src_surface == rt)
2258 TRACE("Blit from active render target to a swapchain\n");
2259 }
2260 else if (src_swapchain && dst_surface == rt)
2261 {
2262 FIXME("Implement blit from a swapchain to the active render target\n");
2264 }
2265
2266 if ((src_swapchain || src_surface == rt) && !dst_swapchain)
2267 {
2268 unsigned int src_level, src_width, src_height;
2269 /* Blit from render target to texture */
2270 BOOL stretchx;
2271
2272 /* P8 read back is not implemented */
2273 if (src_texture->resource.format->id == WINED3DFMT_P8_UINT
2274 || dst_texture->resource.format->id == WINED3DFMT_P8_UINT)
2275 {
2276 TRACE("P8 read back not supported by frame buffer to texture blit\n");
2278 }
2279
2281 {
2282 TRACE("Color keying not supported by frame buffer to texture blit\n");
2284 /* Destination color key is checked above */
2285 }
2286
2287 if (dst_rect->right - dst_rect->left != src_rect->right - src_rect->left)
2288 stretchx = TRUE;
2289 else
2290 stretchx = FALSE;
2291
2292 /* Blt is a pretty powerful call, while glCopyTexSubImage2D is not. glCopyTexSubImage cannot
2293 * flip the image nor scale it.
2294 *
2295 * -> If the app asks for an unscaled, upside down copy, just perform one glCopyTexSubImage2D call
2296 * -> If the app wants an image width an unscaled width, copy it line per line
2297 * -> If the app wants an image that is scaled on the x axis, and the destination rectangle is smaller
2298 * than the frame buffer, draw an upside down scaled image onto the fb, read it back and restore the
2299 * back buffer. This is slower than reading line per line, thus not used for flipping
2300 * -> If the app wants a scaled image with a dest rect that is bigger than the fb, it has to be copied
2301 * pixel by pixel. */
2302 src_level = surface_get_sub_resource_idx(src_surface) % src_texture->level_count;
2303 src_width = wined3d_texture_get_level_width(src_texture, src_level);
2304 src_height = wined3d_texture_get_level_height(src_texture, src_level);
2305 if (!stretchx || dst_rect->right - dst_rect->left > src_width
2306 || dst_rect->bottom - dst_rect->top > src_height)
2307 {
2308 TRACE("No stretching in x direction, using direct framebuffer -> texture copy.\n");
2309 fb_copy_to_texture_direct(dst_surface, src_surface, src_rect, dst_rect, filter);
2310 }
2311 else
2312 {
2313 TRACE("Using hardware stretching to flip / stretch the texture.\n");
2314 fb_copy_to_texture_hwstretch(dst_surface, src_surface, src_rect, dst_rect, filter);
2315 }
2316
2317 return WINED3D_OK;
2318 }
2319
2320 /* Default: Fall back to the generic blt. Not an error, a TRACE is enough */
2321 TRACE("Didn't find any usable render target setup for hw blit, falling back to software\n");
2323}
static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface, const RECT *src_rect, const RECT *dst_rect_in, enum wined3d_texture_filter_type filter)
Definition: surface.c:1754
static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, struct wined3d_surface *src_surface, const RECT *src_rect, const RECT *dst_rect_in, enum wined3d_texture_filter_type filter)
Definition: surface.c:1874
#define WINED3D_BLT_DST_CKEY
Definition: wined3d.h:1360
#define WINED3D_OK
Definition: wined3d.h:37
#define WINED3D_BLT_SRC_CKEY
Definition: wined3d.h:1362
#define WINED3D_BLT_DST_CKEY_OVERRIDE
Definition: wined3d.h:1361
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
static struct wined3d_surface * wined3d_rendertarget_view_get_surface(const struct wined3d_rendertarget_view *view)

Referenced by wined3d_surface_blt().

◆ surface_convert_format()

static struct wined3d_texture * surface_convert_format ( struct wined3d_texture src_texture,
unsigned int  sub_resource_idx,
const struct wined3d_format dst_format 
)
static

Definition at line 1476 of file surface.c.

1478{
1479 unsigned int texture_level = sub_resource_idx % src_texture->level_count;
1480 const struct wined3d_format *src_format = src_texture->resource.format;
1481 struct wined3d_device *device = src_texture->resource.device;
1482 const struct d3dfmt_converter_desc *conv = NULL;
1483 const struct wined3d_gl_info *gl_info = NULL;
1484 unsigned int src_row_pitch, src_slice_pitch;
1485 struct wined3d_context *context = NULL;
1486 struct wined3d_texture *dst_texture;
1487 struct wined3d_bo_address src_data;
1489 DWORD map_binding;
1490
1491 if (!(conv = find_converter(src_format->id, dst_format->id)) && (!device->d3d_initialized
1492 || !is_identity_fixup(src_format->color_fixup) || src_format->conv_byte_count
1493 || !is_identity_fixup(dst_format->color_fixup) || dst_format->conv_byte_count
1495 {
1496 FIXME("Cannot find a conversion function from format %s to %s.\n",
1497 debug_d3dformat(src_format->id), debug_d3dformat(dst_format->id));
1498 return NULL;
1499 }
1500
1501 /* FIXME: Multisampled conversion? */
1502 desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
1503 desc.format = dst_format->id;
1504 desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
1505 desc.multisample_quality = 0;
1508 desc.width = wined3d_texture_get_level_width(src_texture, texture_level);
1509 desc.height = wined3d_texture_get_level_height(src_texture, texture_level);
1510 desc.depth = 1;
1511 desc.size = 0;
1514 NULL, NULL, &wined3d_null_parent_ops, &dst_texture)))
1515 {
1516 ERR("Failed to create a destination texture for conversion.\n");
1517 return NULL;
1518 }
1519
1520 if (device->d3d_initialized)
1521 {
1523 gl_info = context->gl_info;
1524 }
1525
1526 map_binding = src_texture->resource.map_binding;
1527 if (!wined3d_texture_load_location(src_texture, sub_resource_idx, context, map_binding))
1528 ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding));
1529 wined3d_texture_get_pitch(src_texture, texture_level, &src_row_pitch, &src_slice_pitch);
1530 wined3d_texture_get_memory(src_texture, sub_resource_idx, &src_data, map_binding);
1531
1532 if (conv)
1533 {
1534 unsigned int dst_row_pitch, dst_slice_pitch;
1535 struct wined3d_bo_address dst_data;
1536 const BYTE *src;
1537 BYTE *dst;
1538
1539 map_binding = dst_texture->resource.map_binding;
1540 if (!wined3d_texture_load_location(dst_texture, 0, context, map_binding))
1541 ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
1542 wined3d_texture_get_pitch(dst_texture, 0, &dst_row_pitch, &dst_slice_pitch);
1543 wined3d_texture_get_memory(dst_texture, 0, &dst_data, map_binding);
1544
1545 src = context_map_bo_address(context, &src_data,
1546 src_texture->sub_resources[sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
1548 &dst_data, dst_texture->sub_resources[0].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
1549
1550 conv->convert(src, dst, src_row_pitch, dst_row_pitch, desc.width, desc.height);
1551
1552 wined3d_texture_invalidate_location(dst_texture, 0, ~map_binding);
1555 }
1556 else
1557 {
1558 RECT src_rect = {0, 0, desc.width, desc.height};
1559 POINT dst_point = {0, 0};
1560
1561 TRACE("Using upload conversion.\n");
1562
1565 wined3d_surface_upload_data(dst_texture->sub_resources[0].u.surface, gl_info, src_format,
1566 &src_rect, src_row_pitch, &dst_point, FALSE, wined3d_const_bo_address(&src_data));
1567
1570 }
1571
1572 if (context)
1574
1575 return dst_texture;
1576}
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2831
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2802
static const struct d3dfmt_converter_desc * find_converter(enum wined3d_format_id from, enum wined3d_format_id to)
Definition: surface.c:1456
void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, BOOL srgb, const struct wined3d_const_bo_address *data)
Definition: surface.c:779
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1546
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
Definition: texture.c:3511
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
static const WCHAR desc[]
Definition: protectdata.c:36
void(* convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
Definition: surface.c:1416
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:6815
#define WINED3D_TEXTURE_CREATE_DISCARD
Definition: wined3d.h:1559
@ WINED3D_MULTISAMPLE_NONE
Definition: wined3d.h:554
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:56
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:700
#define WINED3D_MAP_READ
Definition: wined3d.h:939
#define WINED3D_TEXTURE_CREATE_MAPPABLE
Definition: wined3d.h:1558
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:57
#define WINED3D_MAP_WRITE
Definition: wined3d.h:938
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:915
#define WINED3DUSAGE_PRIVATE
Definition: wined3d.h:916
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:58

Referenced by surface_cpu_blt().

◆ surface_cpu_blt()

static HRESULT surface_cpu_blt ( struct wined3d_texture dst_texture,
unsigned int  dst_sub_resource_idx,
const struct wined3d_box dst_box,
struct wined3d_texture src_texture,
unsigned int  src_sub_resource_idx,
const struct wined3d_box src_box,
DWORD  flags,
const struct wined3d_blt_fx fx,
enum wined3d_texture_filter_type  filter 
)
static

Definition at line 3298 of file surface.c.

3302{
3303 unsigned int bpp, src_height, src_width, dst_height, dst_width, row_byte_count;
3304 struct wined3d_device *device = dst_texture->resource.device;
3305 const struct wined3d_format *src_format, *dst_format;
3306 struct wined3d_texture *converted_texture = NULL;
3307 struct wined3d_bo_address src_data, dst_data;
3308 unsigned int src_fmt_flags, dst_fmt_flags;
3309 struct wined3d_map_desc dst_map, src_map;
3310 struct wined3d_context *context = NULL;
3311 unsigned int x, sx, xinc, y, sy, yinc;
3312 unsigned int texture_level;
3314 BOOL same_sub_resource;
3315 DWORD map_binding;
3316 const BYTE *sbase;
3317 const BYTE *sbuf;
3318 BYTE *dbuf;
3319
3320 TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_box %s, src_texture %p, "
3321 "src_sub_resource_idx %u, src_box %s, flags %#x, fx %p, filter %s.\n",
3322 dst_texture, dst_sub_resource_idx, debug_box(dst_box), src_texture,
3323 src_sub_resource_idx, debug_box(src_box), flags, fx, debug_d3dtexturefiltertype(filter));
3324
3325 if (device->d3d_initialized)
3327
3328 if (src_texture == dst_texture && src_sub_resource_idx == dst_sub_resource_idx)
3329 {
3330 same_sub_resource = TRUE;
3331
3332 map_binding = dst_texture->resource.map_binding;
3333 texture_level = dst_sub_resource_idx % dst_texture->level_count;
3334 if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, map_binding))
3335 ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
3336 wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding);
3337 wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
3338 wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
3339 dst_map.data = context_map_bo_address(context, &dst_data,
3340 dst_texture->sub_resources[dst_sub_resource_idx].size,
3342
3343 src_map = dst_map;
3344 src_format = dst_texture->resource.format;
3345 dst_format = src_format;
3346 dst_fmt_flags = dst_texture->resource.format_flags;
3347 src_fmt_flags = dst_fmt_flags;
3348 }
3349 else
3350 {
3351 same_sub_resource = FALSE;
3352 dst_format = dst_texture->resource.format;
3353 dst_fmt_flags = dst_texture->resource.format_flags;
3354 if (!(flags & WINED3D_BLT_RAW) && dst_texture->resource.format->id != src_texture->resource.format->id)
3355 {
3356 if (!(converted_texture = surface_convert_format(src_texture, src_sub_resource_idx, dst_format)))
3357 {
3358 FIXME("Cannot convert %s to %s.\n", debug_d3dformat(src_texture->resource.format->id),
3359 debug_d3dformat(dst_texture->resource.format->id));
3360 if (context)
3363 }
3364 src_texture = converted_texture;
3365 src_sub_resource_idx = 0;
3366 }
3367 src_format = src_texture->resource.format;
3368 src_fmt_flags = src_texture->resource.format_flags;
3369
3370 map_binding = src_texture->resource.map_binding;
3371 texture_level = src_sub_resource_idx % src_texture->level_count;
3372 if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, map_binding))
3373 ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding));
3374 wined3d_texture_get_pitch(src_texture, texture_level, &src_map.row_pitch, &src_map.slice_pitch);
3375 wined3d_texture_get_memory(src_texture, src_sub_resource_idx, &src_data, map_binding);
3376 src_map.data = context_map_bo_address(context, &src_data,
3377 src_texture->sub_resources[src_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_READ);
3378
3379 map_binding = dst_texture->resource.map_binding;
3380 texture_level = dst_sub_resource_idx % dst_texture->level_count;
3381 if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, map_binding))
3382 ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
3383 wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding);
3384 wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch);
3385 wined3d_texture_get_memory(dst_texture, dst_sub_resource_idx, &dst_data, map_binding);
3386 dst_map.data = context_map_bo_address(context, &dst_data,
3387 dst_texture->sub_resources[dst_sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
3388 }
3389 flags &= ~WINED3D_BLT_RAW;
3390
3391 bpp = dst_format->byte_count;
3392 src_height = src_box->bottom - src_box->top;
3393 src_width = src_box->right - src_box->left;
3394 dst_height = dst_box->bottom - dst_box->top;
3395 dst_width = dst_box->right - dst_box->left;
3396 row_byte_count = dst_width * bpp;
3397
3398 sbase = (BYTE *)src_map.data
3399 + ((src_box->top / src_format->block_height) * src_map.row_pitch)
3400 + ((src_box->left / src_format->block_width) * src_format->block_byte_count);
3401 dbuf = (BYTE *)dst_map.data
3402 + ((dst_box->top / dst_format->block_height) * dst_map.row_pitch)
3403 + ((dst_box->left / dst_format->block_width) * dst_format->block_byte_count);
3404
3405 if (src_fmt_flags & dst_fmt_flags & WINED3DFMT_FLAG_BLOCKS)
3406 {
3407 TRACE("%s -> %s copy.\n", debug_d3dformat(src_format->id), debug_d3dformat(dst_format->id));
3408
3409 if (same_sub_resource)
3410 {
3411 FIXME("Only plain blits supported on compressed surfaces.\n");
3412 hr = E_NOTIMPL;
3413 goto release;
3414 }
3415
3416 if (src_height != dst_height || src_width != dst_width)
3417 {
3418 WARN("Stretching not supported on compressed surfaces.\n");
3420 goto release;
3421 }
3422
3423 hr = surface_cpu_blt_compressed(sbase, dbuf,
3424 src_map.row_pitch, dst_map.row_pitch, dst_width, dst_height,
3425 src_format, flags, fx);
3426 goto release;
3427 }
3428
3430 && (src_width != dst_width || src_height != dst_height))
3431 {
3432 /* Can happen when d3d9 apps do a StretchRect() call which isn't handled in GL. */
3433 static int once;
3434 if (!once++) FIXME("Filter %s not supported in software blit.\n", debug_d3dtexturefiltertype(filter));
3435 }
3436
3437 xinc = (src_width << 16) / dst_width;
3438 yinc = (src_height << 16) / dst_height;
3439
3440 if (!flags)
3441 {
3442 /* No effects, we can cheat here. */
3443 if (dst_width == src_width)
3444 {
3445 if (dst_height == src_height)
3446 {
3447 /* No stretching in either direction. This needs to be as fast
3448 * as possible. */
3449 sbuf = sbase;
3450
3451 /* Check for overlapping surfaces. */
3452 if (!same_sub_resource || dst_box->top < src_box->top
3453 || dst_box->right <= src_box->left || src_box->right <= dst_box->left)
3454 {
3455 /* No overlap, or dst above src, so copy from top downwards. */
3456 for (y = 0; y < dst_height; ++y)
3457 {
3458 memcpy(dbuf, sbuf, row_byte_count);
3459 sbuf += src_map.row_pitch;
3460 dbuf += dst_map.row_pitch;
3461 }
3462 }
3463 else if (dst_box->top > src_box->top)
3464 {
3465 /* Copy from bottom upwards. */
3466 sbuf += src_map.row_pitch * dst_height;
3467 dbuf += dst_map.row_pitch * dst_height;
3468 for (y = 0; y < dst_height; ++y)
3469 {
3470 sbuf -= src_map.row_pitch;
3471 dbuf -= dst_map.row_pitch;
3472 memcpy(dbuf, sbuf, row_byte_count);
3473 }
3474 }
3475 else
3476 {
3477 /* Src and dst overlapping on the same line, use memmove. */
3478 for (y = 0; y < dst_height; ++y)
3479 {
3480 memmove(dbuf, sbuf, row_byte_count);
3481 sbuf += src_map.row_pitch;
3482 dbuf += dst_map.row_pitch;
3483 }
3484 }
3485 }
3486 else
3487 {
3488 /* Stretching in y direction only. */
3489 for (y = sy = 0; y < dst_height; ++y, sy += yinc)
3490 {
3491 sbuf = sbase + (sy >> 16) * src_map.row_pitch;
3492 memcpy(dbuf, sbuf, row_byte_count);
3493 dbuf += dst_map.row_pitch;
3494 }
3495 }
3496 }
3497 else
3498 {
3499 /* Stretching in X direction. */
3500 unsigned int last_sy = ~0u;
3501 for (y = sy = 0; y < dst_height; ++y, sy += yinc)
3502 {
3503 sbuf = sbase + (sy >> 16) * src_map.row_pitch;
3504
3505 if ((sy >> 16) == (last_sy >> 16))
3506 {
3507 /* This source row is the same as last source row -
3508 * Copy the already stretched row. */
3509 memcpy(dbuf, dbuf - dst_map.row_pitch, row_byte_count);
3510 }
3511 else
3512 {
3513#define STRETCH_ROW(type) \
3514do { \
3515 const type *s = (const type *)sbuf; \
3516 type *d = (type *)dbuf; \
3517 for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
3518 d[x] = s[sx >> 16]; \
3519} while(0)
3520
3521 switch(bpp)
3522 {
3523 case 1:
3525 break;
3526 case 2:
3528 break;
3529 case 4:
3531 break;
3532 case 3:
3533 {
3534 const BYTE *s;
3535 BYTE *d = dbuf;
3536 for (x = sx = 0; x < dst_width; x++, sx+= xinc)
3537 {
3538 DWORD pixel;
3539
3540 s = sbuf + 3 * (sx >> 16);
3541 pixel = s[0] | (s[1] << 8) | (s[2] << 16);
3542 d[0] = (pixel ) & 0xff;
3543 d[1] = (pixel >> 8) & 0xff;
3544 d[2] = (pixel >> 16) & 0xff;
3545 d += 3;
3546 }
3547 break;
3548 }
3549 default:
3550 FIXME("Stretched blit not implemented for bpp %u.\n", bpp * 8);
3552 goto error;
3553 }
3554#undef STRETCH_ROW
3555 }
3556 dbuf += dst_map.row_pitch;
3557 last_sy = sy;
3558 }
3559 }
3560 }
3561 else
3562 {
3563 LONG dstyinc = dst_map.row_pitch, dstxinc = bpp;
3564 DWORD keylow = 0xffffffff, keyhigh = 0, keymask = 0xffffffff;
3565 DWORD destkeylow = 0x0, destkeyhigh = 0xffffffff, destkeymask = 0xffffffff;
3568 {
3569 /* The color keying flags are checked for correctness in ddraw. */
3571 {
3572 keylow = src_texture->async.src_blt_color_key.color_space_low_value;
3573 keyhigh = src_texture->async.src_blt_color_key.color_space_high_value;
3574 }
3576 {
3577 keylow = fx->src_color_key.color_space_low_value;
3578 keyhigh = fx->src_color_key.color_space_high_value;
3579 }
3580
3582 {
3583 /* Destination color keys are taken from the source surface! */
3584 destkeylow = src_texture->async.dst_blt_color_key.color_space_low_value;
3585 destkeyhigh = src_texture->async.dst_blt_color_key.color_space_high_value;
3586 }
3588 {
3589 destkeylow = fx->dst_color_key.color_space_low_value;
3590 destkeyhigh = fx->dst_color_key.color_space_high_value;
3591 }
3592
3593 if (bpp == 1)
3594 {
3595 keymask = 0xff;
3596 }
3597 else
3598 {
3599 DWORD masks[3];
3600 get_color_masks(src_format, masks);
3601 keymask = masks[0] | masks[1] | masks[2];
3602 }
3605 }
3606
3607 if (flags & WINED3D_BLT_FX)
3608 {
3609 BYTE *dTopLeft, *dTopRight, *dBottomLeft, *dBottomRight, *tmp;
3610 LONG tmpxy;
3611 dTopLeft = dbuf;
3612 dTopRight = dbuf + ((dst_width - 1) * bpp);
3613 dBottomLeft = dTopLeft + ((dst_height - 1) * dst_map.row_pitch);
3614 dBottomRight = dBottomLeft + ((dst_width - 1) * bpp);
3615
3616 if (fx->fx & WINEDDBLTFX_ARITHSTRETCHY)
3617 {
3618 /* I don't think we need to do anything about this flag. */
3619 WARN("Nothing done for WINEDDBLTFX_ARITHSTRETCHY.\n");
3620 }
3622 {
3623 tmp = dTopRight;
3624 dTopRight = dTopLeft;
3625 dTopLeft = tmp;
3626 tmp = dBottomRight;
3627 dBottomRight = dBottomLeft;
3628 dBottomLeft = tmp;
3629 dstxinc = dstxinc * -1;
3630 }
3631 if (fx->fx & WINEDDBLTFX_MIRRORUPDOWN)
3632 {
3633 tmp = dTopLeft;
3634 dTopLeft = dBottomLeft;
3635 dBottomLeft = tmp;
3636 tmp = dTopRight;
3637 dTopRight = dBottomRight;
3638 dBottomRight = tmp;
3639 dstyinc = dstyinc * -1;
3640 }
3641 if (fx->fx & WINEDDBLTFX_NOTEARING)
3642 {
3643 /* I don't think we need to do anything about this flag. */
3644 WARN("Nothing done for WINEDDBLTFX_NOTEARING.\n");
3645 }
3646 if (fx->fx & WINEDDBLTFX_ROTATE180)
3647 {
3648 tmp = dBottomRight;
3649 dBottomRight = dTopLeft;
3650 dTopLeft = tmp;
3651 tmp = dBottomLeft;
3652 dBottomLeft = dTopRight;
3653 dTopRight = tmp;
3654 dstxinc = dstxinc * -1;
3655 dstyinc = dstyinc * -1;
3656 }
3657 if (fx->fx & WINEDDBLTFX_ROTATE270)
3658 {
3659 tmp = dTopLeft;
3660 dTopLeft = dBottomLeft;
3661 dBottomLeft = dBottomRight;
3662 dBottomRight = dTopRight;
3663 dTopRight = tmp;
3664 tmpxy = dstxinc;
3665 dstxinc = dstyinc;
3666 dstyinc = tmpxy;
3667 dstxinc = dstxinc * -1;
3668 }
3669 if (fx->fx & WINEDDBLTFX_ROTATE90)
3670 {
3671 tmp = dTopLeft;
3672 dTopLeft = dTopRight;
3673 dTopRight = dBottomRight;
3674 dBottomRight = dBottomLeft;
3675 dBottomLeft = tmp;
3676 tmpxy = dstxinc;
3677 dstxinc = dstyinc;
3678 dstyinc = tmpxy;
3679 dstyinc = dstyinc * -1;
3680 }
3682 {
3683 /* I don't think we need to do anything about this flag. */
3684 WARN("Nothing done for WINEDDBLTFX_ZBUFFERBASEDEST.\n");
3685 }
3686 dbuf = dTopLeft;
3687 flags &= ~(WINED3D_BLT_FX);
3688 }
3689
3690#define COPY_COLORKEY_FX(type) \
3691do { \
3692 const type *s; \
3693 type *d = (type *)dbuf, *dx, tmp; \
3694 for (y = sy = 0; y < dst_height; ++y, sy += yinc) \
3695 { \
3696 s = (const type *)(sbase + (sy >> 16) * src_map.row_pitch); \
3697 dx = d; \
3698 for (x = sx = 0; x < dst_width; ++x, sx += xinc) \
3699 { \
3700 tmp = s[sx >> 16]; \
3701 if (((tmp & keymask) < keylow || (tmp & keymask) > keyhigh) \
3702 && ((dx[0] & destkeymask) >= destkeylow && (dx[0] & destkeymask) <= destkeyhigh)) \
3703 { \
3704 dx[0] = tmp; \
3705 } \
3706 dx = (type *)(((BYTE *)dx) + dstxinc); \
3707 } \
3708 d = (type *)(((BYTE *)d) + dstyinc); \
3709 } \
3710} while(0)
3711
3712 switch (bpp)
3713 {
3714 case 1:
3716 break;
3717 case 2:
3719 break;
3720 case 4:
3722 break;
3723 case 3:
3724 {
3725 const BYTE *s;
3726 BYTE *d = dbuf, *dx;
3727 for (y = sy = 0; y < dst_height; ++y, sy += yinc)
3728 {
3729 sbuf = sbase + (sy >> 16) * src_map.row_pitch;
3730 dx = d;
3731 for (x = sx = 0; x < dst_width; ++x, sx+= xinc)
3732 {
3733 DWORD pixel, dpixel = 0;
3734 s = sbuf + 3 * (sx>>16);
3735 pixel = s[0] | (s[1] << 8) | (s[2] << 16);
3736 dpixel = dx[0] | (dx[1] << 8 ) | (dx[2] << 16);
3737 if (((pixel & keymask) < keylow || (pixel & keymask) > keyhigh)
3738 && ((dpixel & keymask) >= destkeylow || (dpixel & keymask) <= keyhigh))
3739 {
3740 dx[0] = (pixel ) & 0xff;
3741 dx[1] = (pixel >> 8) & 0xff;
3742 dx[2] = (pixel >> 16) & 0xff;
3743 }
3744 dx += dstxinc;
3745 }
3746 d += dstyinc;
3747 }
3748 break;
3749 }
3750 default:
3751 FIXME("%s color-keyed blit not implemented for bpp %u.\n",
3752 (flags & WINED3D_BLT_SRC_CKEY) ? "Source" : "Destination", bpp * 8);
3754 goto error;
3755#undef COPY_COLORKEY_FX
3756 }
3757 }
3758
3759error:
3760 if (flags)
3761 FIXME(" Unsupported flags %#x.\n", flags);
3762
3763release:
3765 if (!same_sub_resource)
3767 if (SUCCEEDED(hr) && dst_texture->swapchain && dst_texture->swapchain->front_buffer == dst_texture)
3768 {
3769 SetRect(&dst_texture->swapchain->front_buffer_update,
3770 dst_box->left, dst_box->top, dst_box->right, dst_box->bottom);
3771 dst_texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(dst_texture->swapchain);
3772 }
3773 if (converted_texture)
3774 wined3d_texture_decref(converted_texture);
3775 if (context)
3777
3778 return hr;
3779}
#define E_NOTIMPL
Definition: ddrawi.h:99
DWORD bpp
Definition: surface.c:185
#define STRETCH_ROW(type)
static void get_color_masks(const struct wined3d_format *format, DWORD *masks)
Definition: surface.c:242
static struct wined3d_texture * surface_convert_format(struct wined3d_texture *src_texture, unsigned int sub_resource_idx, const struct wined3d_format *dst_format)
Definition: surface.c:1476
static HRESULT surface_cpu_blt_compressed(const BYTE *src_data, BYTE *dst_data, UINT src_pitch, UINT dst_pitch, UINT update_w, UINT update_h, const struct wined3d_format *format, DWORD flags, const struct wined3d_blt_fx *fx)
Definition: surface.c:3195
#define COPY_COLORKEY_FX(type)
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1023
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:3939
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define SUCCEEDED(hr)
Definition: intsafe.h:50
if(dx< 0)
Definition: linetemp.h:194
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define for
Definition: utility.h:88
HRESULT hr
Definition: shlfolder.c:183
UINT left
Definition: wined3d.h:1839
UINT right
Definition: wined3d.h:1841
UINT bottom
Definition: wined3d.h:1842
UINT top
Definition: wined3d.h:1840
#define WINEDDBLTFX_ROTATE270
Definition: wined3d.h:1351
#define WINEDDBLTFX_NOTEARING
Definition: wined3d.h:1347
#define WINEDDBLTFX_MIRRORUPDOWN
Definition: wined3d.h:1345
#define WINEDDBLTFX_ROTATE90
Definition: wined3d.h:1353
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:46
#define WINEDDBLTFX_ZBUFFERBASEDEST
Definition: wined3d.h:1357
#define WINEDDBLTFX_ARITHSTRETCHY
Definition: wined3d.h:1341
#define WINEDDBLTFX_ROTATE180
Definition: wined3d.h:1349
#define WINEDDBLTFX_MIRRORLEFTRIGHT
Definition: wined3d.h:1343
#define WINED3D_BLT_RAW
Definition: wined3d.h:1366
#define WINED3DFMT_FLAG_BLOCKS
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by cpu_blitter_blit(), and wined3d_surface_blt().

◆ surface_cpu_blt_colour_fill()

static void surface_cpu_blt_colour_fill ( struct wined3d_rendertarget_view view,
const struct wined3d_box box,
const struct wined3d_color colour 
)
static

Definition at line 3781 of file surface.c.

3783{
3784 struct wined3d_device *device = view->resource->device;
3785 struct wined3d_context *context = NULL;
3786 struct wined3d_texture *texture;
3787 struct wined3d_bo_address data;
3788 unsigned int x, y, w, h, bpp;
3789 struct wined3d_map_desc map;
3790 DWORD map_binding;
3791 BYTE *row;
3792 DWORD c;
3793
3794 TRACE("view %p, box %s, colour %s.\n", view, debug_box(box), debug_color(colour));
3795
3796 if (view->format_flags & WINED3DFMT_FLAG_BLOCKS)
3797 {
3798 FIXME("Not implemented for format %s.\n", debug_d3dformat(view->format->id));
3799 return;
3800 }
3801
3802 if (view->format->id != view->resource->format->id)
3803 FIXME("View format %s doesn't match resource format %s.\n",
3804 debug_d3dformat(view->format->id), debug_d3dformat(view->resource->format->id));
3805
3806 if (view->resource->type == WINED3D_RTYPE_BUFFER)
3807 {
3808 FIXME("Not implemented for buffers.\n");
3809 return;
3810 }
3811
3812 if (device->d3d_initialized)
3814
3815 c = wined3d_format_convert_from_float(view->format, colour);
3816 bpp = view->format->byte_count;
3817 w = box->right - box->left;
3818 h = box->bottom - box->top;
3819
3820 texture = texture_from_resource(view->resource);
3821 map_binding = texture->resource.map_binding;
3822 if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, map_binding))
3823 ERR("Failed to load the sub-resource into %s.\n", wined3d_debug_location(map_binding));
3824 wined3d_texture_invalidate_location(texture, view->sub_resource_idx, ~map_binding);
3825 wined3d_texture_get_pitch(texture, view->sub_resource_idx % texture->level_count,
3826 &map.row_pitch, &map.slice_pitch);
3827 wined3d_texture_get_memory(texture, view->sub_resource_idx, &data, map_binding);
3829 texture->sub_resources[view->sub_resource_idx].size, GL_PIXEL_UNPACK_BUFFER, WINED3D_MAP_WRITE);
3830 map.data = (BYTE *)map.data
3831 + (box->front * map.slice_pitch)
3832 + ((box->top / view->format->block_height) * map.row_pitch)
3833 + ((box->left / view->format->block_width) * view->format->block_byte_count);
3834
3835 switch (bpp)
3836 {
3837 case 1:
3838 for (x = 0; x < w; ++x)
3839 {
3840 ((BYTE *)map.data)[x] = c;
3841 }
3842 break;
3843
3844 case 2:
3845 for (x = 0; x < w; ++x)
3846 {
3847 ((WORD *)map.data)[x] = c;
3848 }
3849 break;
3850
3851 case 3:
3852 {
3853 row = map.data;
3854 for (x = 0; x < w; ++x, row += 3)
3855 {
3856 row[0] = (c ) & 0xff;
3857 row[1] = (c >> 8) & 0xff;
3858 row[2] = (c >> 16) & 0xff;
3859 }
3860 break;
3861 }
3862 case 4:
3863 for (x = 0; x < w; ++x)
3864 {
3865 ((DWORD *)map.data)[x] = c;
3866 }
3867 break;
3868
3869 default:
3870 FIXME("Not implemented for bpp %u.\n", bpp);
3871 wined3d_resource_unmap(view->resource, view->sub_resource_idx);
3872 return;
3873 }
3874
3875 row = map.data;
3876 for (y = 1; y < h; ++y)
3877 {
3878 row += map.row_pitch;
3879 memcpy(row, map.data, w * bpp);
3880 }
3881
3883 if (context)
3885}
Definition: _map.h:48
HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
Definition: resource.c:382
DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, const struct wined3d_color *color)
Definition: utils.c:5227
const char * debug_color(const struct wined3d_color *color)
Definition: utils.c:3948
#define c
Definition: ke_i.h:80
enum view_type type

Referenced by cpu_blitter_clear().

◆ surface_cpu_blt_compressed()

static HRESULT surface_cpu_blt_compressed ( const BYTE src_data,
BYTE dst_data,
UINT  src_pitch,
UINT  dst_pitch,
UINT  update_w,
UINT  update_h,
const struct wined3d_format format,
DWORD  flags,
const struct wined3d_blt_fx fx 
)
static

Definition at line 3195 of file surface.c.

3198{
3199 UINT row_block_count;
3200 const BYTE *src_row;
3201 BYTE *dst_row;
3202 UINT x, y;
3203
3204 src_row = src_data;
3205 dst_row = dst_data;
3206
3207 row_block_count = (update_w + format->block_width - 1) / format->block_width;
3208
3209 if (!flags)
3210 {
3211 for (y = 0; y < update_h; y += format->block_height)
3212 {
3213 memcpy(dst_row, src_row, row_block_count * format->block_byte_count);
3214 src_row += src_pitch;
3215 dst_row += dst_pitch;
3216 }
3217
3218 return WINED3D_OK;
3219 }
3220
3222 {
3223 src_row += (((update_h / format->block_height) - 1) * src_pitch);
3224
3225 switch (format->id)
3226 {
3227 case WINED3DFMT_DXT1:
3228 for (y = 0; y < update_h; y += format->block_height)
3229 {
3230 struct block
3231 {
3232 WORD color[2];
3233 BYTE control_row[4];
3234 };
3235
3236 const struct block *s = (const struct block *)src_row;
3237 struct block *d = (struct block *)dst_row;
3238
3239 for (x = 0; x < row_block_count; ++x)
3240 {
3241 d[x].color[0] = s[x].color[0];
3242 d[x].color[1] = s[x].color[1];
3243 d[x].control_row[0] = s[x].control_row[3];
3244 d[x].control_row[1] = s[x].control_row[2];
3245 d[x].control_row[2] = s[x].control_row[1];
3246 d[x].control_row[3] = s[x].control_row[0];
3247 }
3248 src_row -= src_pitch;
3249 dst_row += dst_pitch;
3250 }
3251 return WINED3D_OK;
3252
3253 case WINED3DFMT_DXT2:
3254 case WINED3DFMT_DXT3:
3255 for (y = 0; y < update_h; y += format->block_height)
3256 {
3257 struct block
3258 {
3259 WORD alpha_row[4];
3260 WORD color[2];
3261 BYTE control_row[4];
3262 };
3263
3264 const struct block *s = (const struct block *)src_row;
3265 struct block *d = (struct block *)dst_row;
3266
3267 for (x = 0; x < row_block_count; ++x)
3268 {
3269 d[x].alpha_row[0] = s[x].alpha_row[3];
3270 d[x].alpha_row[1] = s[x].alpha_row[2];
3271 d[x].alpha_row[2] = s[x].alpha_row[1];
3272 d[x].alpha_row[3] = s[x].alpha_row[0];
3273 d[x].color[0] = s[x].color[0];
3274 d[x].color[1] = s[x].color[1];
3275 d[x].control_row[0] = s[x].control_row[3];
3276 d[x].control_row[1] = s[x].control_row[2];
3277 d[x].control_row[2] = s[x].control_row[1];
3278 d[x].control_row[3] = s[x].control_row[0];
3279 }
3280 src_row -= src_pitch;
3281 dst_row += dst_pitch;
3282 }
3283 return WINED3D_OK;
3284
3285 default:
3286 FIXME("Compressed flip not implemented for format %s.\n",
3287 debug_d3dformat(format->id));
3288 return E_NOTIMPL;
3289 }
3290 }
3291
3292 FIXME("Unsupported blit on compressed surface (format %s, flags %#x, DDFX %#x).\n",
3293 debug_d3dformat(format->id), flags, flags & WINED3D_BLT_FX ? fx->fx : 0);
3294
3295 return E_NOTIMPL;
3296}
GLuint color
Definition: glext.h:6243
@ WINED3DFMT_DXT2
Definition: wined3d.h:240
@ WINED3DFMT_DXT1
Definition: wined3d.h:239
@ WINED3DFMT_DXT3
Definition: wined3d.h:241
static unsigned int block
Definition: xmlmemory.c:101

Referenced by surface_cpu_blt().

◆ surface_depth_blt_fbo()

static void surface_depth_blt_fbo ( const struct wined3d_device device,
struct wined3d_surface src_surface,
DWORD  src_location,
const RECT src_rect,
struct wined3d_surface dst_surface,
DWORD  dst_location,
const RECT dst_rect 
)
static

Definition at line 262 of file surface.c.

265{
266 unsigned int dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
267 unsigned int src_sub_resource_idx = surface_get_sub_resource_idx(src_surface);
268 struct wined3d_texture *dst_texture = dst_surface->container;
269 struct wined3d_texture *src_texture = src_surface->container;
270 const struct wined3d_gl_info *gl_info;
271 struct wined3d_context *context;
272 DWORD src_mask, dst_mask;
273 GLbitfield gl_mask;
274
275 TRACE("device %p\n", device);
276 TRACE("src_surface %p, src_location %s, src_rect %s,\n",
277 src_surface, wined3d_debug_location(src_location), wine_dbgstr_rect(src_rect));
278 TRACE("dst_surface %p, dst_location %s, dst_rect %s.\n",
279 dst_surface, wined3d_debug_location(dst_location), wine_dbgstr_rect(dst_rect));
280
281 src_mask = src_texture->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
282 dst_mask = dst_texture->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
283
284 if (src_mask != dst_mask)
285 {
286 ERR("Incompatible formats %s and %s.\n",
287 debug_d3dformat(src_texture->resource.format->id),
288 debug_d3dformat(dst_texture->resource.format->id));
289 return;
290 }
291
292 if (!src_mask)
293 {
294 ERR("Not a depth / stencil format: %s.\n",
295 debug_d3dformat(src_texture->resource.format->id));
296 return;
297 }
298
299 gl_mask = 0;
301 gl_mask |= GL_DEPTH_BUFFER_BIT;
303 gl_mask |= GL_STENCIL_BUFFER_BIT;
304
306 if (!context->valid)
307 {
309 WARN("Invalid context, skipping blit.\n");
310 return;