ReactOS  0.4.14-dev-49-gfb4591c
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)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define d
Definition: ke_i.h:81
unsigned char BYTE
Definition: mem.h:68
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97

◆ 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)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039

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 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned char BYTE
Definition: mem.h:68

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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
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
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
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
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
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
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
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
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
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_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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define TRACE(s)
Definition: solgame.cpp:4
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static unsigned short float_32_to_16(const float *in)
Definition: surface.c:1062

◆ 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 }
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
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
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
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define e
Definition: ke_i.h:82
#define TRACE(s)
Definition: solgame.cpp:4
#define d
Definition: ke_i.h:81
static DNS_RECORDW r2
Definition: record.c:38
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static BYTE cliptobyte(int x)
Definition: surface.c:1205
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define e
Definition: ke_i.h:82
#define TRACE(s)
Definition: solgame.cpp:4
#define d
Definition: ke_i.h:81
static DNS_RECORDW r2
Definition: record.c:38
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static BYTE cliptobyte(int x)
Definition: surface.c:1205
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ 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 WINED3D_BLT_SRC_CKEY_OVERRIDE
Definition: wined3d.h:1363
Definition: http.c:6587
LONG top
Definition: windef.h:292
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
struct wined3d_resource resource
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINED3D_BLT_FX
Definition: wined3d.h:1359
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define WINED3D_BLT_ALPHA_TEST
Definition: wined3d.h:1368
GLfixed fx
Definition: tritemp.h:482
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
#define ERR(fmt,...)
Definition: debug.h:109
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
LONG bottom
Definition: windef.h:294
UINT op
Definition: effect.c:223
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
#define memset(x, y, z)
Definition: compat.h:39
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ 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 
3914  if (flags & WINED3DCLEAR_TARGET)
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 }
#define max(a, b)
Definition: svc.c:63
struct wined3d_rendertarget_view * render_targets[MAX_RENDER_TARGET_VIEWS]
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define WINED3DCLEAR_STENCIL
Definition: wined3d.h:999
#define WINED3DCLEAR_ZBUFFER
Definition: wined3d.h:998
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
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
#define FIXME(fmt,...)
Definition: debug.h:110
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 GLint GLint j
Definition: glfuncs.h:250
const GLubyte * c
Definition: glext.h:8905
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define WINED3DCLEAR_TARGET
Definition: wined3d.h:997
struct wined3d_rendertarget_view * depth_stencil
#define min(a, b)
Definition: monoChain.cc:55
static IOleDocumentView * view
Definition: activex.c:1749
LONG bottom
Definition: windef.h:294
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3973
Definition: palette.c:467

◆ 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 }
Definition: http.c:6587
struct wined3d_blitter * next
static unsigned __int64 next
Definition: rand_nt.c:6
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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 }
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
struct opengl_funcs gl_ops
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
Definition: http.c:6587
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
LONG right
Definition: windef.h:293
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_ENV_MODE
Definition: gl.h:643
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
#define GL_REPLACE
Definition: gl.h:460
#define GL_TEXTURE_ENV
Definition: gl.h:642
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define checkGLcall(A)
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
LONG bottom
Definition: windef.h:294
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291

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 }
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
#define TRUE
Definition: types.h:120
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
Definition: http.c:6587
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context)
Definition: context.c:2954
LONG top
Definition: windef.h:292
struct wined3d_resource resource
LONG left
Definition: windef.h:291
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
LONG right
Definition: windef.h:293
GLint GLint GLint yoffset
Definition: gl.h:1547
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: devices.h:37
#define FIXME_(x)
Definition: compat.h:67
#define eps
void context_release(struct wined3d_context *context)
Definition: context.c:1571
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
#define WINED3D_LOCATION_TEXTURE_RGB
#define checkGLcall(A)
unsigned int UINT
Definition: ndis.h:50
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
LONG bottom
Definition: windef.h:294
const struct wined3d_gl_info * gl_info
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
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

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 }
#define ORM_FBO
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
#define GL_BACK
Definition: gl.h:271
static long backup()
Definition: maze.c:403
#define TRUE
Definition: types.h:120
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
#define GL_QUADS
Definition: gl.h:197
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
Definition: http.c:6587
struct wined3d_swapchain * swapchain
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context)
Definition: context.c:2954
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define GL_NEAREST
Definition: gl.h:678
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
LONG top
Definition: windef.h:292
struct wined3d_resource resource
LONG left
Definition: windef.h:291
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2734
LONG right
Definition: windef.h:293
static struct wined3d_texture_sub_resource * surface_get_sub_resource(struct wined3d_surface *surface)
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define GL_FRONT
Definition: gl.h:270
#define GL_AUX1
Definition: gl.h:476
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
smooth NULL
Definition: ftsmooth.c:416
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
GLint GLint bottom
Definition: glext.h:7726
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
#define WINED3D_TEXTURE_NORMALIZED_COORDS
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
GLenum src
Definition: glext.h:6340
unsigned int GLenum
Definition: gl.h:150
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_AUX0
Definition: gl.h:475
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
#define WINED3D_LOCATION_TEXTURE_RGB
#define checkGLcall(A)
unsigned int UINT
Definition: ndis.h:50
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
#define GL_TEXTURE_2D
Definition: gl.h:645
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
LONG bottom
Definition: windef.h:294
#define GL_RGBA
Definition: gl.h:503
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
const struct wined3d_gl_info * gl_info
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)

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  {
2695  blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
2696  else
2697  blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
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 }
#define WINED3DFMT_FLAG_STENCIL
Definition: http.c:6587
struct wined3d_blitter * next
unsigned int format_flags
const struct wined3d_format * format
wined3d_blit_op
Definition: devices.h:37
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
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
struct wined3d_device * device
#define TRACE(s)
Definition: solgame.cpp:4
#define ERR(fmt,...)
Definition: debug.h:109
static unsigned __int64 next
Definition: rand_nt.c:6
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
#define WINED3DFMT_FLAG_DEPTH
UINT op
Definition: effect.c:223
struct wined3d_texture * container
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ 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 }
struct wined3d_blitter * next
GLint GLfloat GLint stencil
Definition: glext.h:6260
Definition: devices.h:37
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
static unsigned __int64 next
Definition: rand_nt.c:6

◆ 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 }
Definition: http.c:6587
struct wined3d_blitter * next
static unsigned __int64 next
Definition: rand_nt.c:6
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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 }
#define ORM_FBO
#define WINED3DFMT_FLAG_STENCIL
#define TRUE
Definition: types.h:120
static const char * dst_format
Definition: dib.c:1133
unsigned int access
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
const struct wined3d_format * format
struct color_fixup_desc color_fixup
#define WINED3D_LOCATION_DRAWABLE
static BOOL is_scaling_fixup(struct color_fixup_desc fixup)
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
#define WINED3DFMT_FLAG_FBO_ATTACHABLE
enum wined3d_format_id id
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]
struct wined3d_fbo_ops fbo_ops
#define WINED3DFMT_FLAG_DEPTH

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  {
2918  blit_op = WINED3D_BLIT_OP_DEPTH_BLIT;
2919  else
2920  blit_op = WINED3D_BLIT_OP_COLOR_BLIT;
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");
2939  dump_color_fixup_desc(src_format->color_fixup);
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 WINED3DFMT_FLAG_STENCIL
#define TRUE
Definition: types.h:120
static const char * dst_format
Definition: dib.c:1133
Definition: http.c:6587
unsigned int access
#define WARN(fmt,...)
Definition: debug.h:111
const struct wined3d_format * format
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ORM_BACKBUFFER
struct color_fixup_desc color_fixup
#define WINED3D_LOCATION_DRAWABLE
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
enum wined3d_format_id id
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define WINED3DFMT_FLAG_COMPRESSED
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]
#define WINED3DFMT_FLAG_DEPTH
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4844
#define TRACE_ON(x)
Definition: compat.h:65

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);
3095  buffer = wined3d_texture_get_gl_buffer(dst_texture);
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 }
#define ORM_FBO
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
struct opengl_funcs gl_ops
Definition: http.c:6587
struct wined3d_swapchain * swapchain
#define WINED3D_CKEY_SRC_BLT
Definition: wined3d.h:1336
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct wined3d_blitter * next
struct wined3d_resource resource
GLuint buffer
Definition: glext.h:5915
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
struct wined3d_texture::wined3d_texture_async async
Definition: devices.h:37
BOOL supported[WINED3D_GL_EXT_COUNT]
smooth NULL
Definition: ftsmooth.c:416
struct wined3d_device * device
#define WINED3D_LOCATION_DRAWABLE
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
#define GL_NOTEQUAL
Definition: gl.h:298
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key)
Definition: texture.c:1235
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
unsigned int GLenum
Definition: gl.h:150
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
static unsigned __int64 next
Definition: rand_nt.c:6
#define checkGLcall(A)
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066
#define GL_ALPHA_TEST
Definition: gl.h:366
#define GL_TEXTURE_2D
Definition: gl.h:645
#define STATE_FRAMEBUFFER
UINT op
Definition: effect.c:223
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
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect)
Definition: surface.c:2164

◆ 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 
3000  if (flags & WINED3DCLEAR_TARGET)
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;
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  {
3027  next_flags |= flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL);
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 }
#define ORM_FBO
static BOOL ffp_blitter_use_cpu_clear(struct wined3d_rendertarget_view *view)
Definition: surface.c:2971
struct wined3d_rendertarget_view * render_targets[MAX_RENDER_TARGET_VIEWS]
struct wined3d_blitter * next
#define WINED3DCLEAR_STENCIL
Definition: wined3d.h:999
GLint GLfloat GLint stencil
Definition: glext.h:6260
#define WINED3DCLEAR_ZBUFFER
Definition: wined3d.h:998
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
Definition: devices.h:37
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define WINED3DFMT_FLAG_FBO_ATTACHABLE
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
#define WINED3DCLEAR_TARGET
Definition: wined3d.h:997
struct wined3d_rendertarget_view * depth_stencil
static unsigned __int64 next
Definition: rand_nt.c:6
static IOleDocumentView * view
Definition: activex.c:1749

◆ 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 }
Definition: http.c:6587
struct wined3d_blitter * next
static unsigned __int64 next
Definition: rand_nt.c:6
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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;
2975  DWORD locations;
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 }
int resource
Definition: rdpsnd_sgi.c:44
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
GLsizei const GLint * locations
Definition: glext.h:10542
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define WINED3D_TEXTURE_CONVERTED
#define WINED3D_TEXTURE_PIN_SYSMEM
#define WINED3D_LOCATION_DISCARDED

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 }
BOOL wined3d_dxtn_supported(void)
Definition: dxtn.c:510
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
static const struct d3dfmt_converter_desc converters[]
Definition: surface.c:1419
smooth NULL
Definition: ftsmooth.c:416
static const struct d3dfmt_converter_desc dxtn_converters[]
Definition: surface.c:1429
#define ARRAY_SIZE(a)
Definition: main.h:24
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 }
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
GLfloat f
Definition: glext.h:7540
int isinf(double x)
int ret
int isnan(double x)
GLuint in
Definition: glext.h:9616
DWORD exp
Definition: msg.c:15681
_Check_return_ __CRT_INLINE float __CRTDECL fabsf(_In_ float x)
Definition: math.h:164
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by convert_r32_float_r16_float(), and format_from_vec4().

◆ 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 }
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
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static const BYTE masks[8]
Definition: dib.c:2760

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 TRUE
Definition: types.h:120
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define WINED3D_LOCATION_RB_MULTISAMPLE
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define WINED3D_LOCATION_TEXTURE_RGB
#define WINED3D_LOCATION_TEXTURE_SRGB

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;
2792  DWORD location;
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 }
Definition: http.c:6587
static GLuint wined3d_texture_get_texture_name(const struct wined3d_texture *texture, const struct wined3d_context *context, BOOL srgb)
struct wined3d_blitter * next
LONG top
Definition: windef.h:292
struct wined3d_resource resource
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define WINED3D_TEXTURE_IS_SRGB
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6389
#define GL_EXTCALL(f)
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1605
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
unsigned long DWORD
Definition: ntddk_ex.h:95
#define location(file, line)
Definition: kmtest.h:18
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL texture2d_is_full_rect(const struct wined3d_texture *texture, unsigned int level, const RECT *r)
Definition: surface.c:249
static unsigned __int64 next
Definition: rand_nt.c:6
unsigned int GLuint
Definition: gl.h:159
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
#define WINED3D_LOCATION_TEXTURE_RGB
#define checkGLcall(A)
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
LONG bottom
Definition: windef.h:294
UINT op
Definition: effect.c:223
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
#define WINED3D_LOCATION_TEXTURE_SRGB
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

◆ 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 }
struct wined3d_blitter * next
GLint GLfloat GLint stencil
Definition: glext.h:6260
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:109
static unsigned __int64 next
Definition: rand_nt.c:6

◆ 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 }
Definition: http.c:6587
struct wined3d_blitter * next
static unsigned __int64 next
Definition: rand_nt.c:6
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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 
1693 error:
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 }
void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device)
Definition: context.c:2981
GLint level
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
struct opengl_funcs gl_ops
#define error(str)
Definition: mkdosfs.c:1605
Definition: http.c:6587
GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context)
Definition: context.c:2954
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
GLuint buffer
Definition: glext.h:5915
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
#define GL_READ_WRITE
Definition: glext.h:343
#define GL_PACK_ROW_LENGTH
Definition: gl.h:628
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
GLint GLint bottom
Definition: glext.h:7726
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 context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
#define GL_EXTCALL(f)
void context_restore(struct wined3d_context *context, struct wined3d_surface *restore)
Definition: context.c:1606
#define TRACE(s)
Definition: solgame.cpp:4
static struct wined3d_surface * context_get_rt_surface(const struct wined3d_context *context)
GLenum GLuint texture
Definition: glext.h:6295
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
unsigned int GLenum
Definition: gl.h:150
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
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_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
#define checkGLcall(A)
#define STATE_FRAMEBUFFER
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476
Definition: mem.c:156
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
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
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
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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;
385  GLenum buffer;
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  {
399  case WINED3D_TEXF_LINEAR:
400  gl_filter = GL_LINEAR;
401  break;
402 
403  default:
404  FIXME("Unsupported filter mode %s (%#x).\n", debug_d3dtexturefiltertype(filter), filter);
405  case WINED3D_TEXF_NONE:
406  case WINED3D_TEXF_POINT:
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);
452  buffer = wined3d_texture_get_gl_buffer(src_texture);
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);
469  buffer = wined3d_texture_get_gl_buffer(dst_texture);
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 }
#define MAX_RENDER_TARGETS
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define abs(i)
Definition: fconv.c:206
struct opengl_funcs gl_ops
Definition: http.c:6587
struct wined3d_swapchain * swapchain
#define GL_NEAREST
Definition: gl.h:678
#define WARN(fmt,...)
Definition: debug.h:111
LONG top
Definition: windef.h:292
struct wined3d_resource resource
GLuint buffer
Definition: glext.h:5915
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
static enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
Definition: wined3d.h:400
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
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6389
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINED3D_LOCATION_RB_RESOLVED
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
void context_check_fbo_status(const struct wined3d_context *context, GLenum target)
Definition: context.c:381
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#define GL_DRAW_FRAMEBUFFER
Definition: glext.h:1699
#define GL_SCISSOR_TEST
Definition: gl.h:589
void context_restore(struct wined3d_context *context, struct wined3d_surface *restore)
Definition: context.c:1606
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1605
#define TRACE(s)
Definition: solgame.cpp:4
static struct wined3d_surface * context_get_rt_surface(const struct wined3d_context *context)
const char * debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type)
Definition: utils.c:4532
const char * wine_dbgstr_rect(const RECT *rect)
#define GL_LINEAR
Definition: gl.h:421
GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture)
Definition: texture.c:51
unsigned int GLenum
Definition: gl.h:150
#define STATE_RENDER(a)
static BOOL texture2d_is_full_rect(const struct wined3d_texture *texture, unsigned int level, const RECT *r)
Definition: surface.c:249
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_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
static BOOL is_multisample_location(const struct wined3d_texture *texture, DWORD location)
Definition: surface.c:360
#define GL_TRUE
Definition: gl.h:174
#define checkGLcall(A)
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
#define STATE_FRAMEBUFFER
#define GL_READ_FRAMEBUFFER
Definition: glext.h:1698
LONG bottom
Definition: windef.h:294
struct wined3d_fbo_ops fbo_ops
void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
Definition: context.c:2701
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect)
Definition: surface.c:2164

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");
2205  return WINED3DERR_INVALIDCALL;
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");
2216  return WINED3DERR_INVALIDCALL;
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");
2231  return WINED3DERR_INVALIDCALL;
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");
2239  return WINED3DERR_INVALIDCALL;
2240  }
2241 
2242  if (dst_swapchain && dst_swapchain == src_swapchain)
2243  {
2244  FIXME("Implement hardware blit between two surfaces on the same swapchain\n");
2245  return WINED3DERR_INVALIDCALL;
2246  }
2247 
2248  if (dst_swapchain && src_swapchain)
2249  {
2250  FIXME("Implement hardware blit between two different swapchains\n");
2251  return WINED3DERR_INVALIDCALL;
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");
2263  return WINED3DERR_INVALIDCALL;
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");
2277  return WINED3DERR_INVALIDCALL;
2278  }
2279 
2281  {
2282  TRACE("Color keying not supported by frame buffer to texture blit\n");
2283  return WINED3DERR_INVALIDCALL;
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");
2322  return WINED3DERR_INVALIDCALL;
2323 }
#define WINED3D_BLT_SRC_CKEY
Definition: wined3d.h:1362
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define TRUE
Definition: types.h:120
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
#define WINED3D_BLT_SRC_CKEY_OVERRIDE
Definition: wined3d.h:1363
struct wined3d_swapchain * swapchain
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WARN(fmt,...)
Definition: debug.h:111
LONG top
Definition: windef.h:292
struct wined3d_resource resource
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define WINED3D_BLT_DST_CKEY_OVERRIDE
Definition: wined3d.h:1361
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
static struct wined3d_surface * wined3d_rendertarget_view_get_surface(const struct wined3d_rendertarget_view *view)
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
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 TRACE(s)
Definition: solgame.cpp:4
const char * debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type)
Definition: utils.c:4532
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
GLfixed fx
Definition: tritemp.h:482
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
LONG bottom
Definition: windef.h:294
#define WINED3D_BLT_DST_CKEY
Definition: wined3d.h:1360
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by wined3d_surface_blt().

◆ surface_convert_format()

static struct wined3d_texture* surface_convert_format ( struct wined3d_texture src_texture,