ReactOS 0.4.16-dev-334-g4d9f67c
utils.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdio.h>
#include "wined3d_private.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Classes

struct  wined3d_format_channels
 
struct  wined3d_typed_format_info
 
struct  wined3d_typeless_format_depth_stencil_info
 
struct  wined3d_format_ddi_info
 
struct  wined3d_format_base_flags
 
struct  wined3d_format_block_info
 
struct  wined3d_format_vertex_info
 
struct  wined3d_format_texture_info
 
struct  wined3d_format_srgb_info
 
struct  debug_buffer
 

Macros

#define WINED3D_FORMAT_FOURCC_BASE   (WINED3DFMT_BC7_UNORM_SRGB + 1)
 
#define WINED3D_FORMAT_COUNT   (WINED3D_FORMAT_FOURCC_BASE + ARRAY_SIZE(format_index_remap))
 
#define FMT_TO_STR(format_id)   case format_id: return #format_id
 
#define DEVTYPE_TO_STR(dev)   case dev: return #dev
 
#define ACCESS_TO_STR(x)   if (access & x) { debug_append(&buffer, #x, " | "); access &= ~x; }
 
#define WINED3DUSAGE_TO_STR(x)   if (usage & x) { debug_append(&buffer, #x, " | "); usage &= ~x; }
 
#define WINED3DUSAGEQUERY_TO_STR(x)   if (usage & x) { debug_append(&buffer, #x, " | "); usage &= ~x; }
 
#define WINED3DDECLMETHOD_TO_STR(u)   case u: return #u
 
#define WINED3DDECLUSAGE_TO_STR(u)   case u: return #u
 
#define WINED3D_TO_STR(x)   case x: return #x
 
#define WINED3D_TO_STR(x)   case x: return #x
 
#define PRIM_TO_STR(prim)   case prim: return #prim
 
#define D3DSTATE_TO_STR(u)   case u: return #u
 
#define D3DSTATE_TO_STR(u)   case u: return #u
 
#define D3DTEXTUREFILTERTYPE_TO_STR(u)   case u: return #u
 
#define D3DSTATE_TO_STR(u)   case u: return #u
 
#define D3DTOP_TO_STR(u)   case u: return #u
 
#define TSTYPE_TO_STR(tstype)   case tstype: return #tstype
 
#define WINED3D_TO_STR(type)   case type: return #type
 
#define WINED3D_TO_STR(x)   case x: return #x
 
#define FBOSTATUS_TO_STR(u)   case u: return #u
 
#define GLERROR_TO_STR(u)   case u: return #u
 
#define WINED3D_TO_STR(x)   case x: return #x
 
#define WINED3D_TO_STR(x)   case x: return #x
 
#define ARG1   0x01
 
#define ARG2   0x02
 
#define ARG0   0x04
 
#define LOCATION_TO_STR(x)   if (location & x) { debug_append(&buffer, #x, " | "); location &= ~x; }
 

Enumerations

enum  wined3d_channel_type {
  WINED3D_CHANNEL_TYPE_NONE , WINED3D_CHANNEL_TYPE_UNORM , WINED3D_CHANNEL_TYPE_SNORM , WINED3D_CHANNEL_TYPE_UINT ,
  WINED3D_CHANNEL_TYPE_SINT , WINED3D_CHANNEL_TYPE_FLOAT , WINED3D_CHANNEL_TYPE_DEPTH , WINED3D_CHANNEL_TYPE_STENCIL ,
  WINED3D_CHANNEL_TYPE_UNUSED
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
static void convert_l4a4_unorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r5g5_snorm_l6_unorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r5g5_snorm_l6_unorm_ext (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r5g5_snorm_l6_unorm_nv (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r8g8_snorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r8g8_snorm_l8x8_unorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r8g8_snorm_l8x8_unorm_nv (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r8g8b8a8_snorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r16g16_snorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r16g16 (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_r32g32_float (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_s1_uint_d15_unorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_s4x4_uint_d24_unorm (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void convert_s8_uint_d24_float (const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch, UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth)
 
static void x8_d24_unorm_upload (const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int width, unsigned int height, unsigned int depth)
 
static void x8_d24_unorm_download (const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int width, unsigned int height, unsigned int depth)
 
static BOOL color_in_range (const struct wined3d_color_key *color_key, DWORD color)
 
static void convert_p8_uint_b8g8r8a8_unorm (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
static void convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
static void convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
static void convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
static void convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
static void convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key (const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width, unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key)
 
const struct wined3d_color_key_conversionwined3d_format_get_color_key_conversion (const struct wined3d_texture *texture, BOOL need_alpha_ck)
 
static int get_format_idx (enum wined3d_format_id format_id)
 
static struct wined3d_formatget_format_internal (struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id)
 
static void copy_format (struct wined3d_format *dst_format, const struct wined3d_format *src_format)
 
static void format_set_flag (struct wined3d_format *format, unsigned int flag)
 
static void format_clear_flag (struct wined3d_format *format, unsigned int flag)
 
static enum wined3d_channel_type map_channel_type (char t)
 
static BOOL init_format_base_info (struct wined3d_gl_info *gl_info)
 
static BOOL init_format_block_info (struct wined3d_gl_info *gl_info)
 
static GLenum wined3d_gl_type_to_enum (enum wined3d_gl_resource_type type)
 
static void delete_fbo_attachment (const struct wined3d_gl_info *gl_info, enum wined3d_gl_resource_type d3d_type, GLuint object)
 
static void create_and_bind_fbo_attachment (const struct wined3d_gl_info *gl_info, unsigned int flags, enum wined3d_gl_resource_type d3d_type, GLuint *object, GLenum internal, GLenum format, GLenum type)
 
static void draw_test_quad (struct wined3d_caps_gl_ctx *ctx, const struct wined3d_vec3 *geometry, const struct wined3d_color *color)
 
static void check_fbo_compat (struct wined3d_caps_gl_ctx *ctx, struct wined3d_format *format)
 
static void query_format_flag (struct wined3d_gl_info *gl_info, struct wined3d_format *format, GLint internal, GLenum pname, DWORD flag, const char *string)
 
static void init_format_fbo_compat_info (struct wined3d_caps_gl_ctx *ctx)
 
static GLenum lookup_gl_view_class (GLenum internal_format)
 
static void query_view_class (struct wined3d_format *format)
 
static void query_internal_format (struct wined3d_adapter *adapter, struct wined3d_format *format, const struct wined3d_format_texture_info *texture_info, struct wined3d_gl_info *gl_info, BOOL srgb_write_supported, BOOL srgb_format)
 
static BOOL init_format_texture_info (struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
 
static BOOL color_match (DWORD c1, DWORD c2, BYTE max_diff)
 
static BOOL check_filter (const struct wined3d_gl_info *gl_info, GLenum internal)
 
static void init_format_filter_info (struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor)
 
static void apply_format_fixups (struct wined3d_adapter *adapter, struct wined3d_gl_info *gl_info)
 
static unsigned int calculate_vertex_attribute_size (GLenum type, unsigned int component_count)
 
static BOOL init_format_vertex_info (struct wined3d_gl_info *gl_info)
 
static BOOL init_typeless_formats (struct wined3d_gl_info *gl_info)
 
static void init_format_gen_mipmap_info (struct wined3d_gl_info *gl_info)
 
BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits (struct wined3d_caps_gl_ctx *ctx)
 
static float wined3d_adapter_find_polyoffset_scale (struct wined3d_caps_gl_ctx *ctx, GLenum format)
 
static void init_format_depth_bias_scale (struct wined3d_caps_gl_ctx *ctx, const struct wined3d_d3d_info *d3d_info)
 
BOOL wined3d_adapter_init_format_info (struct wined3d_adapter *adapter, struct wined3d_caps_gl_ctx *ctx)
 
const struct wined3d_formatwined3d_get_format (const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
 
BOOL wined3d_format_is_depth_view (enum wined3d_format_id resource_format_id, enum wined3d_format_id view_format_id)
 
void wined3d_format_calculate_pitch (const struct wined3d_format *format, unsigned int alignment, unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
 
UINT wined3d_format_calculate_size (const struct wined3d_format *format, UINT alignment, UINT width, UINT height, UINT depth)
 
BOOL wined3d_formats_are_srgb_variants (enum wined3d_format_id format1, enum wined3d_format_id format2)
 
const chardebug_box (const struct wined3d_box *box)
 
const chardebug_color (const struct wined3d_color *color)
 
const chardebug_ivec4 (const struct wined3d_ivec4 *v)
 
const chardebug_uvec4 (const struct wined3d_uvec4 *v)
 
const chardebug_vec4 (const struct wined3d_vec4 *v)
 
const chardebug_d3dformat (enum wined3d_format_id format_id)
 
const chardebug_d3ddevicetype (enum wined3d_device_type device_type)
 
static void init_debug_buffer (struct debug_buffer *buffer, const char *default_string)
 
static void debug_append (struct debug_buffer *buffer, const char *str, const char *separator)
 
const charwined3d_debug_resource_access (DWORD access)
 
const chardebug_d3dusage (DWORD usage)
 
const chardebug_d3dusagequery (DWORD usage)
 
const chardebug_d3ddeclmethod (enum wined3d_decl_method method)
 
const chardebug_d3ddeclusage (enum wined3d_decl_usage usage)
 
const chardebug_d3dinput_classification (enum wined3d_input_classification classification)
 
const chardebug_d3dresourcetype (enum wined3d_resource_type resource_type)
 
const chardebug_d3dprimitivetype (enum wined3d_primitive_type primitive_type)
 
const chardebug_d3drenderstate (enum wined3d_render_state state)
 
const chardebug_d3dsamplerstate (enum wined3d_sampler_state state)
 
const chardebug_d3dtexturefiltertype (enum wined3d_texture_filter_type filter_type)
 
const chardebug_d3dtexturestate (enum wined3d_texture_stage_state state)
 
const chardebug_d3dtop (enum wined3d_texture_op d3dtop)
 
const chardebug_d3dtstype (enum wined3d_transform_state tstype)
 
const chardebug_shader_type (enum wined3d_shader_type type)
 
const chardebug_d3dstate (DWORD state)
 
const chardebug_fboattachment (GLenum attachment)
 
const chardebug_fbostatus (GLenum status)
 
const chardebug_glerror (GLenum error)
 
static const chardebug_fixup_channel_source (enum fixup_channel_source source)
 
static const chardebug_complex_fixup (enum complex_fixup fixup)
 
void dump_color_fixup_desc (struct color_fixup_desc fixup)
 
BOOL is_invalid_op (const struct wined3d_state *state, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3)
 
void get_identity_matrix (struct wined3d_matrix *mat)
 
void get_modelview_matrix (const struct wined3d_context *context, const struct wined3d_state *state, unsigned int index, struct wined3d_matrix *mat)
 
void get_projection_matrix (const struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_matrix *mat)
 
static void compute_texture_matrix (const struct wined3d_gl_info *gl_info, const struct wined3d_matrix *matrix, DWORD flags, BOOL calculated_coords, BOOL transformed, enum wined3d_format_id format_id, BOOL ffp_proj_control, struct wined3d_matrix *out_matrix)
 
void get_texture_matrix (const struct wined3d_context *context, const struct wined3d_state *state, unsigned int tex, struct wined3d_matrix *mat)
 
void get_pointsize_minmax (const struct wined3d_context *context, const struct wined3d_state *state, float *out_min, float *out_max)
 
void get_pointsize (const struct wined3d_context *context, const struct wined3d_state *state, float *out_pointsize, float *out_att)
 
void get_fog_start_end (const struct wined3d_context *context, const struct wined3d_state *state, float *start, float *end)
 
DWORD wined3d_format_convert_from_float (const struct wined3d_format *format, const struct wined3d_color *color)
 
static float color_to_float (DWORD color, DWORD size, DWORD offset)
 
void wined3d_format_get_float_color_key (const struct wined3d_format *format, const struct wined3d_color_key *key, struct wined3d_color *float_colors)
 
enum wined3d_format_id pixelformat_for_depth (DWORD depth)
 
void multiply_matrix (struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
 
BOOL invert_matrix_3d (struct wined3d_matrix *out, const struct wined3d_matrix *in)
 
static void swap_rows (float **a, float **b)
 
BOOL invert_matrix (struct wined3d_matrix *out, const struct wined3d_matrix *m)
 
void transpose_matrix (struct wined3d_matrix *out, const struct wined3d_matrix *m)
 
DWORD get_flexible_vertex_size (DWORD d3dvtVertexType)
 
unsigned int wined3d_max_compat_varyings (const struct wined3d_gl_info *gl_info)
 
void gen_ffp_frag_op (const struct wined3d_context *context, const struct wined3d_state *state, struct ffp_frag_settings *settings, BOOL ignore_textype)
 
const struct ffp_frag_descfind_ffp_frag_shader (const struct wine_rb_tree *fragment_shaders, const struct ffp_frag_settings *settings)
 
void add_ffp_frag_shader (struct wine_rb_tree *shaders, struct ffp_frag_desc *desc)
 
void texture_activate_dimensions (const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
 
void sampler_texdim (struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 
int wined3d_ffp_frag_program_key_compare (const void *key, const struct wine_rb_entry *entry)
 
void wined3d_ffp_get_vs_settings (const struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings)
 
int wined3d_ffp_vertex_program_key_compare (const void *key, const struct wine_rb_entry *entry)
 
const charwined3d_debug_location (DWORD location)
 
void wined3d_ftoa (float value, char *s)
 
void wined3d_release_dc (HWND window, HDC dc)
 
BOOL wined3d_clip_blit (const RECT *clip_rect, RECT *clipped, RECT *other)
 
void wined3d_gl_limits_get_uniform_block_range (const struct wined3d_gl_limits *gl_limits, enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count)
 
void wined3d_gl_limits_get_texture_unit_range (const struct wined3d_gl_limits *gl_limits, enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count)
 
BOOL wined3d_array_reserve (void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
 

Variables

struct {
   enum wined3d_format_id   id
 
   unsigned int   idx
 
format_index_remap []
 
static const struct wined3d_format_channels formats []
 
static const struct wined3d_typed_format_info typed_formats []
 
static const struct wined3d_typeless_format_depth_stencil_info typeless_depth_stencil_formats []
 
static const struct wined3d_format_ddi_info ddi_formats []
 
static const struct wined3d_format_base_flags format_base_flags []
 
static const struct wined3d_format_block_info format_block_info []
 
static const struct wined3d_format_vertex_info format_vertex_info []
 
static const struct wined3d_format_texture_info format_texture_info []
 
static const struct wined3d_format_srgb_info format_srgb_info []
 

Macro Definition Documentation

◆ ACCESS_TO_STR

#define ACCESS_TO_STR (   x)    if (access & x) { debug_append(&buffer, #x, " | "); access &= ~x; }

◆ ARG0

#define ARG0   0x04

◆ ARG1

#define ARG1   0x01

◆ ARG2

#define ARG2   0x02

◆ D3DSTATE_TO_STR [1/3]

#define D3DSTATE_TO_STR (   u)    case u: return #u

◆ D3DSTATE_TO_STR [2/3]

#define D3DSTATE_TO_STR (   u)    case u: return #u

◆ D3DSTATE_TO_STR [3/3]

#define D3DSTATE_TO_STR (   u)    case u: return #u

◆ D3DTEXTUREFILTERTYPE_TO_STR

#define D3DTEXTUREFILTERTYPE_TO_STR (   u)    case u: return #u

◆ D3DTOP_TO_STR

#define D3DTOP_TO_STR (   u)    case u: return #u

◆ DEVTYPE_TO_STR

#define DEVTYPE_TO_STR (   dev)    case dev: return #dev

◆ FBOSTATUS_TO_STR

#define FBOSTATUS_TO_STR (   u)    case u: return #u

◆ FMT_TO_STR

#define FMT_TO_STR (   format_id)    case format_id: return #format_id

◆ GLERROR_TO_STR

#define GLERROR_TO_STR (   u)    case u: return #u

◆ LOCATION_TO_STR

#define LOCATION_TO_STR (   x)    if (location & x) { debug_append(&buffer, #x, " | "); location &= ~x; }

◆ PRIM_TO_STR

#define PRIM_TO_STR (   prim)    case prim: return #prim

◆ TSTYPE_TO_STR

#define TSTYPE_TO_STR (   tstype)    case tstype: return #tstype

◆ WINED3D_FORMAT_COUNT

Definition at line 70 of file utils.c.

◆ WINED3D_FORMAT_FOURCC_BASE

#define WINED3D_FORMAT_FOURCC_BASE   (WINED3DFMT_BC7_UNORM_SRGB + 1)

Definition at line 36 of file utils.c.

◆ WINED3D_TO_STR [1/6]

#define WINED3D_TO_STR (   type)    case type: return #type

◆ WINED3D_TO_STR [2/6]

#define WINED3D_TO_STR (   x)    case x: return #x

◆ WINED3D_TO_STR [3/6]

#define WINED3D_TO_STR (   x)    case x: return #x

◆ WINED3D_TO_STR [4/6]

#define WINED3D_TO_STR (   x)    case x: return #x

◆ WINED3D_TO_STR [5/6]

#define WINED3D_TO_STR (   x)    case x: return #x

◆ WINED3D_TO_STR [6/6]

#define WINED3D_TO_STR (   x)    case x: return #x

◆ WINED3DDECLMETHOD_TO_STR

#define WINED3DDECLMETHOD_TO_STR (   u)    case u: return #u

◆ WINED3DDECLUSAGE_TO_STR

#define WINED3DDECLUSAGE_TO_STR (   u)    case u: return #u

◆ WINED3DUSAGE_TO_STR

#define WINED3DUSAGE_TO_STR (   x)    if (usage & x) { debug_append(&buffer, #x, " | "); usage &= ~x; }

◆ WINED3DUSAGEQUERY_TO_STR

#define WINED3DUSAGEQUERY_TO_STR (   x)    if (usage & x) { debug_append(&buffer, #x, " | "); usage &= ~x; }

Enumeration Type Documentation

◆ wined3d_channel_type

Enumerator
WINED3D_CHANNEL_TYPE_NONE 
WINED3D_CHANNEL_TYPE_UNORM 
WINED3D_CHANNEL_TYPE_SNORM 
WINED3D_CHANNEL_TYPE_UINT 
WINED3D_CHANNEL_TYPE_SINT 
WINED3D_CHANNEL_TYPE_FLOAT 
WINED3D_CHANNEL_TYPE_DEPTH 
WINED3D_CHANNEL_TYPE_STENCIL 
WINED3D_CHANNEL_TYPE_UNUSED 

Definition at line 179 of file utils.c.

180{
190};
@ WINED3D_CHANNEL_TYPE_UNUSED
Definition: utils.c:189
@ WINED3D_CHANNEL_TYPE_UNORM
Definition: utils.c:182
@ WINED3D_CHANNEL_TYPE_STENCIL
Definition: utils.c:188
@ WINED3D_CHANNEL_TYPE_FLOAT
Definition: utils.c:186
@ WINED3D_CHANNEL_TYPE_SNORM
Definition: utils.c:183
@ WINED3D_CHANNEL_TYPE_NONE
Definition: utils.c:181
@ WINED3D_CHANNEL_TYPE_UINT
Definition: utils.c:184
@ WINED3D_CHANNEL_TYPE_SINT
Definition: utils.c:185
@ WINED3D_CHANNEL_TYPE_DEPTH
Definition: utils.c:187

Function Documentation

◆ add_ffp_frag_shader()

void add_ffp_frag_shader ( struct wine_rb_tree shaders,
struct ffp_frag_desc desc 
)

Definition at line 6083 of file utils.c.

6084{
6085 /* Note that the key is the implementation independent part of the ffp_frag_desc structure,
6086 * whereas desc points to an extended structure with implementation specific parts. */
6087 if (wine_rb_put(shaders, &desc->settings, &desc->entry) == -1)
6088 {
6089 ERR("Failed to insert ffp frag shader.\n");
6090 }
6091}
#define ERR(fmt,...)
Definition: precomp.h:57
const GLuint * shaders
Definition: glext.h:7538
static const WCHAR desc[]
Definition: protectdata.c:36
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215

Referenced by fragment_prog_arbfp(), set_tex_op_atifs(), and shader_glsl_find_ffp_fragment_shader().

◆ apply_format_fixups()

static void apply_format_fixups ( struct wined3d_adapter adapter,
struct wined3d_gl_info gl_info 
)
static

Definition at line 3203 of file utils.c.

3204{
3205 unsigned int i;
3206 int idx;
3207
3209 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3211
3213 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3215
3217 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3219
3221 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3223
3225 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3227
3228 /* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by
3229 * any driver. */
3230 if (gl_info->supported[NV_TEXTURE_SHADER] || gl_info->supported[EXT_TEXTURE_SNORM])
3231 {
3232 /* R8G8_SNORM and R16G16_SNORM need a fixup of the undefined blue channel. OpenGL
3233 * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
3234 * conversion for this format. */
3236 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3239 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3241 }
3242 else
3243 {
3244 /* Emulate using unsigned formats. This requires load-time conversion in addition to the
3245 * fixups here. */
3247 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3250 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3253 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3256 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3258 }
3259
3260 if (!gl_info->supported[NV_TEXTURE_SHADER])
3261 {
3263 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3265 }
3266
3268 {
3270 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3272
3274 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3276 }
3277 else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
3278 {
3280 gl_info->formats[idx].color_fixup= create_color_fixup_desc(
3282 }
3283
3284 if (!gl_info->supported[APPLE_YCBCR_422] && gl_info->supported[ARB_FRAGMENT_PROGRAM]
3286 {
3289
3292 }
3293 else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
3294 || !gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]))
3295 {
3297 gl_info->formats[idx].glInternal = 0;
3298
3300 gl_info->formats[idx].glInternal = 0;
3301 }
3302
3304 {
3307 gl_info->formats[idx].height_scale.numerator = 3;
3308 gl_info->formats[idx].height_scale.denominator = 2;
3310
3313 gl_info->formats[idx].height_scale.numerator = 3;
3314 gl_info->formats[idx].height_scale.denominator = 2;
3316 }
3317 else
3318 {
3320 gl_info->formats[idx].glInternal = 0;
3321
3323 gl_info->formats[idx].glInternal = 0;
3324 }
3325
3326 if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3327 {
3329 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3332 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3335 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3338 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3341 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3343 }
3344
3345 if (gl_info->supported[ARB_TEXTURE_RG])
3346 {
3348 gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3350 }
3351
3352 if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
3353 {
3355 gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
3356 }
3357
3358 if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
3359 {
3361 gl_info->formats[idx].gl_vtx_format = GL_BGRA;
3362 }
3363
3364 if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX])
3365 {
3366 /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
3367 * It is the job of the vertex buffer code to make sure that the vbos have the right format */
3369 gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
3370
3372 gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
3373 }
3374
3375 if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3376 {
3379
3382
3385 }
3386
3387 if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
3388 {
3391 }
3392
3393 /* ATI instancing hack: Although ATI cards do not support Shader Model
3394 * 3.0, they support instancing. To query if the card supports instancing
3395 * CheckDeviceFormat() with the special format MAKEFOURCC('I','N','S','T')
3396 * is used. Should an application check for this, provide a proper return
3397 * value. We can do instancing with all shader versions, but we need
3398 * vertex shaders.
3399 *
3400 * Additionally applications have to set the D3DRS_POINTSIZE render state
3401 * to MAKEFOURCC('I','N','S','T') once to enable instancing. Wined3d
3402 * doesn't need that and just ignores it.
3403 *
3404 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows. */
3405 /* FIXME: This should just check the shader backend caps. */
3406 if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
3407 {
3410 }
3411
3412 /* Depth bound test. To query if the card supports it CheckDeviceFormat()
3413 * with the special format MAKEFOURCC('N','V','D','B') is used. It is
3414 * enabled by setting D3DRS_ADAPTIVETESS_X render state to
3415 * MAKEFOURCC('N','V','D','B') and then controlled by setting
3416 * D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax) to test
3417 * value. */
3418 if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
3419 {
3422 }
3423
3424 /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
3425 * support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
3426 * RENDERTARGET usage. */
3427 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3428 {
3431 }
3432
3433 for (i = 0; i < gl_info->format_count; ++i)
3434 {
3435 struct wined3d_format *format = &gl_info->formats[i];
3436
3438 continue;
3439
3440 if (is_identity_fixup(format->color_fixup))
3441 continue;
3442
3443 TRACE("Checking support for fixup:\n");
3444 dump_color_fixup_desc(format->color_fixup);
3445 if (!adapter->shader_backend->shader_color_fixup_supported(format->color_fixup)
3446 || !adapter->fragment_pipe->color_fixup_supported(format->color_fixup))
3447 {
3448 TRACE("[FAILED]\n");
3450 }
3451 else
3452 {
3453 TRACE("[OK]\n");
3454 }
3455 }
3456
3457 /* GL_EXT_texture_compression_s3tc does not support 3D textures. Some Windows drivers
3458 * for dx9 GPUs support it, some do not, so not supporting DXTn volumes is OK for d3d9.
3459 *
3460 * Note that GL_NV_texture_compression_vtc adds this functionality to OpenGL, but the
3461 * block layout is not compatible with the one used by d3d. See volume_dxt5_test. */
3463 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3465 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3467 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3469 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3471 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3473 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3475 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3477 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3479 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3481 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3483 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3484 /* Similarly with ATI1N / ATI2N and GL_ARB_texture_compression_rgtc. */
3486 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3488 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3490 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3492 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3494 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3496 gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
3497}
static int get_format_idx(enum wined3d_format_id format_id)
Definition: utils.c:1750
static void format_set_flag(struct wined3d_format *format, unsigned int flag)
Definition: utils.c:1787
unsigned int idx
Definition: utils.c:41
static void format_clear_flag(struct wined3d_format *format, unsigned int flag)
Definition: utils.c:1795
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4851
return adapter
#define GL_BGRA
Definition: gl.h:1485
#define GL_FLOAT
Definition: gl.h:183
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 TRACE(s)
Definition: solgame.cpp:4
Definition: format.c:58
unsigned int format_count
BOOL supported[WINED3D_GL_EXT_COUNT]
struct wined3d_format * formats
@ WINED3DFMT_RESZ
Definition: wined3d.h:254
@ WINED3DFMT_BC5_UNORM
Definition: wined3d.h:219
@ WINED3DFMT_BC2_UNORM_SRGB
Definition: wined3d.h:211
@ WINED3DFMT_INTZ
Definition: wined3d.h:253
@ WINED3DFMT_R16G16_UNORM
Definition: wined3d.h:171
@ WINED3DFMT_BC5_SNORM
Definition: wined3d.h:220
@ WINED3DFMT_DXT2
Definition: wined3d.h:240
@ WINED3DFMT_R32G32_FLOAT
Definition: wined3d.h:150
@ WINED3DFMT_R16G16_SNORM
Definition: wined3d.h:173
@ WINED3DFMT_B8G8R8A8_UNORM
Definition: wined3d.h:223
@ WINED3DFMT_ATI1N
Definition: wined3d.h:247
@ WINED3DFMT_BC2_UNORM
Definition: wined3d.h:210
@ WINED3DFMT_R8G8B8A8_SNORM
Definition: wined3d.h:167
@ WINED3DFMT_NV12
Definition: wined3d.h:258
@ WINED3DFMT_L8A8_UNORM
Definition: wined3d.h:119
@ WINED3DFMT_L4A4_UNORM
Definition: wined3d.h:120
@ WINED3DFMT_BC1_UNORM_SRGB
Definition: wined3d.h:208
@ WINED3DFMT_R16G16B16A16_FLOAT
Definition: wined3d.h:144
@ WINED3DFMT_L8_UNORM
Definition: wined3d.h:118
@ WINED3DFMT_R8G8_SNORM
Definition: wined3d.h:187
@ WINED3DFMT_R5G5_SNORM_L6_UNORM
Definition: wined3d.h:121
@ WINED3DFMT_INST
Definition: wined3d.h:249
@ WINED3DFMT_DXT1
Definition: wined3d.h:239
@ WINED3DFMT_NVDB
Definition: wined3d.h:250
@ WINED3DFMT_R16_FLOAT
Definition: wined3d.h:190
@ WINED3DFMT_DXT3
Definition: wined3d.h:241
@ WINED3DFMT_DXT4
Definition: wined3d.h:242
@ WINED3DFMT_R16G16B16A16_UNORM
Definition: wined3d.h:145
@ WINED3DFMT_BC3_UNORM
Definition: wined3d.h:213
@ WINED3DFMT_R32_FLOAT
Definition: wined3d.h:177
@ WINED3DFMT_R8G8_SNORM_L8X8_UNORM
Definition: wined3d.h:122
@ WINED3DFMT_YV12
Definition: wined3d.h:238
@ WINED3DFMT_DXT5
Definition: wined3d.h:243
@ WINED3DFMT_BC4_UNORM
Definition: wined3d.h:216
@ WINED3DFMT_YUY2
Definition: wined3d.h:237
@ WINED3DFMT_R16G16_FLOAT
Definition: wined3d.h:170
@ WINED3DFMT_P8_UINT
Definition: wined3d.h:117
@ WINED3DFMT_L16_UNORM
Definition: wined3d.h:132
@ WINED3DFMT_BC1_UNORM
Definition: wined3d.h:207
@ WINED3DFMT_UYVY
Definition: wined3d.h:236
@ WINED3DFMT_BC3_UNORM_SRGB
Definition: wined3d.h:214
@ WINED3DFMT_A8_UNORM
Definition: wined3d.h:201
@ WINED3DFMT_ATI2N
Definition: wined3d.h:248
@ WINED3DFMT_BC4_SNORM
Definition: wined3d.h:217
@ ARB_FRAGMENT_PROGRAM
Definition: wined3d_gl.h:70
@ ATI_TEXTURE_COMPRESSION_3DC
Definition: wined3d_gl.h:146
@ ARB_VERTEX_PROGRAM
Definition: wined3d_gl.h:139
@ ARB_TEXTURE_COMPRESSION_RGTC
Definition: wined3d_gl.h:112
@ ARB_FRAMEBUFFER_OBJECT
Definition: wined3d_gl.h:73
@ ARB_VERTEX_SHADER
Definition: wined3d_gl.h:140
@ ARB_TEXTURE_RG
Definition: wined3d_gl.h:126
@ ARB_HALF_FLOAT_VERTEX
Definition: wined3d_gl.h:78
@ EXT_TEXTURE_COMPRESSION_RGTC
Definition: wined3d_gl.h:173
@ ARB_VERTEX_ARRAY_BGRA
Definition: wined3d_gl.h:136
@ EXT_DEPTH_BOUNDS_TEST
Definition: wined3d_gl.h:156
@ ARB_HALF_FLOAT_PIXEL
Definition: wined3d_gl.h:77
@ APPLE_YCBCR_422
Definition: wined3d_gl.h:43
@ NV_TEXTURE_SHADER
Definition: wined3d_gl.h:198
@ WINED3D_GL_LEGACY_CONTEXT
Definition: wined3d_gl.h:213
@ EXT_TEXTURE_SNORM
Definition: wined3d_gl.h:181
static struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
#define WINED3DFMT_FLAG_HEIGHT_SCALE
#define WINED3DFMT_FLAG_RENDERTARGET
@ CHANNEL_SOURCE_ONE
@ CHANNEL_SOURCE_W
@ CHANNEL_SOURCE_X
@ CHANNEL_SOURCE_ZERO
@ CHANNEL_SOURCE_Z
@ CHANNEL_SOURCE_Y
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
@ WINED3D_GL_RES_TYPE_TEX_3D
@ WINED3D_GL_RES_TYPE_TEX_2D
#define WINED3DFMT_FLAG_TEXTURE
#define WINED3D_QUIRK_BROKEN_RGBA16
@ COMPLEX_FIXUP_P8
@ COMPLEX_FIXUP_YUY2
@ COMPLEX_FIXUP_UYVY
@ COMPLEX_FIXUP_NV12
@ COMPLEX_FIXUP_YV12
static struct color_fixup_desc create_color_fixup_desc(int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1, int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)

Referenced by wined3d_adapter_init_format_info().

◆ calculate_vertex_attribute_size()

static unsigned int calculate_vertex_attribute_size ( GLenum  type,
unsigned int  component_count 
)
static

Definition at line 3499 of file utils.c.

3500{
3501 switch (type)
3502 {
3503 case GL_HALF_FLOAT:
3504 return component_count * sizeof(GLhalfNV);
3505 case GL_FLOAT:
3506 return component_count * sizeof(GLfloat);
3507 case GL_BYTE:
3508 return component_count * sizeof(GLbyte);
3509 case GL_UNSIGNED_BYTE:
3510 return component_count * sizeof(GLubyte);
3511 case GL_SHORT:
3512 return component_count * sizeof(GLshort);
3513 case GL_UNSIGNED_SHORT:
3514 return component_count * sizeof(GLushort);
3515 case GL_INT:
3516 return component_count * sizeof(GLint);
3517 case GL_UNSIGNED_INT:
3518 return component_count * sizeof(GLuint);
3520 return sizeof(GLuint);
3521 default:
3522 FIXME("Unhandled GL type %#x.\n", type);
3523 return 0;
3524 }
3525}
#define FIXME(fmt,...)
Definition: precomp.h:53
unsigned int component_count
unsigned char GLubyte
Definition: gl.h:157
signed char GLbyte
Definition: gl.h:154
#define GL_INT
Definition: gl.h:181
short GLshort
Definition: gl.h:155
float GLfloat
Definition: gl.h:161
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_BYTE
Definition: gl.h:177
unsigned int GLuint
Definition: gl.h:159
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define GL_SHORT
Definition: gl.h:179
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
unsigned short GLushort
Definition: gl.h:158
int GLint
Definition: gl.h:156
#define GL_UNSIGNED_INT_2_10_10_10_REV
Definition: gl.h:1497
unsigned short GLhalfNV
Definition: glext.h:5520
#define GL_HALF_FLOAT
Definition: glext.h:1785

Referenced by init_format_vertex_info().

◆ check_fbo_compat()

static void check_fbo_compat ( struct wined3d_caps_gl_ctx ctx,
struct wined3d_format format 
)
static

Definition at line 2234 of file utils.c.

2235{
2236 /* Check if the default internal format is supported as a frame buffer
2237 * target, otherwise fall back to the render target internal.
2238 *
2239 * Try to stick to the standard format if possible, this limits precision differences. */
2240 static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 1.0f};
2241 static const struct wined3d_color half_transparent_red = {1.0f, 0.0f, 0.0f, 0.5f};
2242 const struct wined3d_gl_info *gl_info = ctx->gl_info;
2243 GLenum status, rt_internal = format->rtInternal;
2244 GLuint object, color_rb;
2246 BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
2247
2248 gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2249
2250 for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
2251 {
2252 const char *type_string = "color";
2253
2255 continue;
2256
2257 create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glInternal,
2258 format->glFormat, format->glType);
2259
2261 {
2262 gl_info->fbo_ops.glGenRenderbuffers(1, &color_rb);
2263 gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, color_rb);
2265 gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 16, 1);
2266 else
2267 gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 16, 16);
2268
2269 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER,
2271 checkGLcall("Create and attach color rb attachment");
2272 type_string = "depth / stencil";
2273 }
2274
2275 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2276 checkGLcall("Framebuffer format check");
2277
2279 {
2280 TRACE("Format %s is supported as FBO %s attachment, type %u.\n",
2281 debug_d3dformat(format->id), type_string, type);
2283 format->rtInternal = format->glInternal;
2284 regular_fmt_used = TRUE;
2285 }
2286 else
2287 {
2288 if (!rt_internal)
2289 {
2291 {
2292 WARN("Format %s with rendertarget flag is not supported as FBO color attachment (type %u),"
2293 " and no fallback specified.\n", debug_d3dformat(format->id), type);
2294 format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
2295 }
2296 else
2297 {
2298 TRACE("Format %s is not supported as FBO %s attachment, type %u.\n",
2299 debug_d3dformat(format->id), type_string, type);
2300 }
2301 format->rtInternal = format->glInternal;
2302 }
2303 else
2304 {
2305 TRACE("Format %s is not supported as FBO %s attachment (type %u),"
2306 " trying rtInternal format as fallback.\n",
2307 debug_d3dformat(format->id), type_string, type);
2308
2309 while (gl_info->gl_ops.gl.p_glGetError());
2310
2311 delete_fbo_attachment(gl_info, type, object);
2312 create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->rtInternal,
2313 format->glFormat, format->glType);
2314
2315 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2316 checkGLcall("Framebuffer format check");
2317
2319 {
2320 TRACE("Format %s rtInternal format is supported as FBO %s attachment, type %u.\n",
2321 debug_d3dformat(format->id), type_string, type);
2322 fallback_fmt_used = TRUE;
2323 }
2324 else
2325 {
2326 WARN("Format %s rtInternal format is not supported as FBO %s attachment, type %u.\n",
2327 debug_d3dformat(format->id), type_string, type);
2328 format->flags[type] &= ~WINED3DFMT_FLAG_RENDERTARGET;
2329 }
2330 }
2331 }
2332
2336 && !(format->flags[type] & WINED3DFMT_FLAG_INTEGER)
2338 && format->glFormat != GL_LUMINANCE && format->glFormat != GL_LUMINANCE_ALPHA
2339 && (format->red_size || format->alpha_size))
2340 {
2341 DWORD readback[16 * 16 * 16], color, r_range, a_range;
2342 BYTE r, a;
2343 BOOL match = TRUE;
2344 GLuint rb;
2345
2346 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
2348 {
2349 gl_info->fbo_ops.glGenRenderbuffers(1, &rb);
2350 gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, rb);
2352 gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 16, 1);
2353 else
2354 gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 16, 16);
2355 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
2356 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
2357 checkGLcall("RB attachment");
2358 }
2359
2360 gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
2361 gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2362 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
2363 if (gl_info->gl_ops.gl.p_glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION)
2364 {
2365 while (gl_info->gl_ops.gl.p_glGetError());
2366 TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
2368 format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
2369 }
2370 else
2371 {
2372 gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2374 gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 1);
2375 else
2376 gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 16);
2377 gl_info->gl_ops.gl.p_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2378
2379 draw_test_quad(ctx, NULL, &black);
2380
2381 gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
2382
2383 draw_test_quad(ctx, NULL, &half_transparent_red);
2384
2385 gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2386
2387 switch (type)
2388 {
2390 /* Rebinding texture to workaround a fglrx bug. */
2391 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, object);
2392 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_1D, 0, GL_BGRA,
2393 GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2394 color = readback[7];
2395 break;
2396
2400 /* Rebinding texture to workaround a fglrx bug. */
2401 gl_info->gl_ops.gl.p_glBindTexture(wined3d_gl_type_to_enum(type), object);
2402 gl_info->gl_ops.gl.p_glGetTexImage(wined3d_gl_type_to_enum(type), 0, GL_BGRA,
2403 GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2404 color = readback[7 * 16 + 7];
2405 break;
2406
2408 /* Rebinding texture to workaround a fglrx bug. */
2409 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, object);
2410 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_BGRA,
2411 GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2412 color = readback[7 * 16 + 7];
2413 break;
2414
2416 gl_info->gl_ops.gl.p_glReadPixels(0, 0, 16, 16,
2418 color = readback[7 * 16 + 7];
2419 break;
2420
2423 color = 0;
2424 break;
2425 }
2426 checkGLcall("Post-pixelshader blending check");
2427
2428 a = color >> 24;
2429 r = (color & 0x00ff0000u) >> 16;
2430
2431 r_range = format->red_size < 8 ? 1u << (8 - format->red_size) : 1;
2432 a_range = format->alpha_size < 8 ? 1u << (8 - format->alpha_size) : 1;
2433 if (format->red_size && (r < 0x7f - r_range || r > 0x7f + r_range))
2434 match = FALSE;
2435 else if (format->alpha_size > 1 && (a < 0xbf - a_range || a > 0xbf + a_range))
2436 match = FALSE;
2437 if (!match)
2438 {
2439 TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
2441 TRACE("Color output: %#x\n", color);
2442 format->flags[type] &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING;
2443 }
2444 else
2445 {
2446 TRACE("Format %s supports post-pixelshader blending, type %u.\n",
2448 TRACE("Color output: %#x\n", color);
2450 }
2451 }
2452
2453 if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
2455 {
2456 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
2457 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
2458 gl_info->fbo_ops.glDeleteRenderbuffers(1, &rb);
2459 checkGLcall("RB cleanup");
2460 }
2461 }
2462
2463 if (format->glInternal != format->glGammaInternal)
2464 {
2465 delete_fbo_attachment(gl_info, type, object);
2466 create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glGammaInternal,
2467 format->glFormat, format->glType);
2468
2469 status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2470 checkGLcall("Framebuffer format check");
2471
2473 {
2474 TRACE("Format %s's sRGB format is FBO attachable, type %u.\n",
2477 if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
2478 format->glInternal = format->glGammaInternal;
2479 }
2480 else
2481 {
2482 WARN("Format %s's sRGB format is not FBO attachable, type %u.\n",
2485 }
2486 }
2487 else if (status == GL_FRAMEBUFFER_COMPLETE)
2489
2491 {
2492 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
2493 gl_info->fbo_ops.glDeleteRenderbuffers(1, &color_rb);
2494 }
2495
2496 delete_fbo_attachment(gl_info, type, object);
2497 checkGLcall("Framebuffer format check cleanup");
2498 }
2499
2500 if (fallback_fmt_used && regular_fmt_used)
2501 {
2502 FIXME("Format %s needs different render target formats for different resource types.\n",
2503 debug_d3dformat(format->id));
2506 }
2507}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define WARN(fmt,...)
Definition: precomp.h:61
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static GLenum wined3d_gl_type_to_enum(enum wined3d_gl_resource_type type)
Definition: utils.c:1954
static void create_and_bind_fbo_attachment(const struct wined3d_gl_info *gl_info, unsigned int flags, enum wined3d_gl_resource_type d3d_type, GLuint *object, GLenum internal, GLenum format, GLenum type)
Definition: utils.c:2003
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3980
static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info, enum wined3d_gl_resource_type d3d_type, GLuint object)
Definition: utils.c:1979
static void draw_test_quad(struct wined3d_caps_gl_ctx *ctx, const struct wined3d_vec3 *geometry, const struct wined3d_color *color)
Definition: utils.c:2104
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_RGBA8
Definition: gl.h:762
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define GL_SRC_ALPHA
Definition: gl.h:378
unsigned int GLenum
Definition: gl.h:150
#define GL_LUMINANCE
Definition: gl.h:484
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define GL_BLEND
Definition: gl.h:371
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition: gl.h:1495
#define GL_DEPTH24_STENCIL8
Definition: glext.h:1687
GLuint color
Definition: glext.h:6243
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
Definition: glext.h:1232
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_FRAMEBUFFER_COMPLETE
Definition: glext.h:1707
#define GL_RENDERBUFFER
Definition: glext.h:1733
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_INVALID_FRAMEBUFFER_OPERATION
Definition: glext.h:1672
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define a
Definition: ke_i.h:78
Definition: match.c:28
Definition: ps.c:97
struct opengl_funcs gl_ops
struct wined3d_fbo_ops fbo_ops
@ WINED3DFMT_NULL
Definition: wined3d.h:255
@ EXT_TEXTURE_SRGB_DECODE
Definition: wined3d_gl.h:183
@ EXT_PACKED_DEPTH_STENCIL
Definition: wined3d_gl.h:163
#define WINED3DFMT_FLAG_SRGB_WRITE
#define WINED3DFMT_FLAG_INTEGER
#define WINED3D_QUIRK_LIMITED_TEX_FILTERING
#define WINED3DFMT_FLAG_FBO_ATTACHABLE
wined3d_gl_resource_type
@ WINED3D_GL_RES_TYPE_TEX_CUBE
@ WINED3D_GL_RES_TYPE_BUFFER
@ WINED3D_GL_RES_TYPE_RB
@ WINED3D_GL_RES_TYPE_TEX_RECT
@ WINED3D_GL_RES_TYPE_TEX_1D
@ WINED3D_GL_RES_TYPE_COUNT
#define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
#define WINED3DFMT_FLAG_STENCIL
#define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
#define WINED3DFMT_FLAG_DEPTH
#define checkGLcall(A)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by init_format_fbo_compat_info().

◆ check_filter()

static BOOL check_filter ( const struct wined3d_gl_info gl_info,
GLenum  internal 
)
static

Definition at line 3038 of file utils.c.

3039{
3040 static const DWORD data[] = {0x00000000, 0xffffffff};
3041 GLuint tex, fbo, buffer;
3042 DWORD readback[16 * 1];
3043 BOOL ret = FALSE;
3044
3045 /* Render a filtered texture and see what happens. This is intended to detect the lack of
3046 * float16 filtering on ATI X1000 class cards. The drivers disable filtering instead of
3047 * falling back to software. If this changes in the future this code will get fooled and
3048 * apps might hit the software path due to incorrectly advertised caps.
3049 *
3050 * Its unlikely that this changes however. GL Games like Mass Effect depend on the filter
3051 * disable fallback, if Apple or ATI ever change the driver behavior they will break more
3052 * than Wine. The Linux binary <= r500 driver is not maintained any more anyway
3053 */
3054
3055 while (gl_info->gl_ops.gl.p_glGetError());
3056
3057 gl_info->gl_ops.gl.p_glGenTextures(1, &buffer);
3058 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, buffer);
3059 memset(readback, 0x7e, sizeof(readback));
3060 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 1, 0,
3061 GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, readback);
3062 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3063 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3064 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3065 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3066 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
3067
3068 gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
3069 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
3070 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, internal, 2, 1, 0,
3072 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
3073 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3074 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3075 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3076 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
3077 gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
3078
3079 gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
3080 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3081 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, buffer, 0);
3082 gl_info->gl_ops.gl.p_glDrawBuffer(GL_COLOR_ATTACHMENT0);
3083
3084 gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 1);
3085 gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING);
3086 gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
3087 gl_info->gl_ops.gl.p_glLoadIdentity();
3088 gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
3089 gl_info->gl_ops.gl.p_glLoadIdentity();
3090
3091 gl_info->gl_ops.gl.p_glClearColor(0, 1, 0, 0);
3092 gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
3093
3094 gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
3095 gl_info->gl_ops.gl.p_glTexCoord2f(0.0, 0.0);
3096 gl_info->gl_ops.gl.p_glVertex2f(-1.0f, -1.0f);
3097 gl_info->gl_ops.gl.p_glTexCoord2f(1.0, 0.0);
3098 gl_info->gl_ops.gl.p_glVertex2f(1.0f, -1.0f);
3099 gl_info->gl_ops.gl.p_glTexCoord2f(0.0, 1.0);
3100 gl_info->gl_ops.gl.p_glVertex2f(-1.0f, 1.0f);
3101 gl_info->gl_ops.gl.p_glTexCoord2f(1.0, 1.0);
3102 gl_info->gl_ops.gl.p_glVertex2f(1.0f, 1.0f);
3103 gl_info->gl_ops.gl.p_glEnd();
3104
3105 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, buffer);
3106 memset(readback, 0x7f, sizeof(readback));
3107 gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, readback);
3108 if (color_match(readback[6], 0xffffffff, 5) || color_match(readback[6], 0x00000000, 5)
3109 || color_match(readback[9], 0xffffffff, 5) || color_match(readback[9], 0x00000000, 5))
3110 {
3111 TRACE("Read back colors 0x%08x and 0x%08x close to unfiltered color, assuming no filtering\n",
3112 readback[6], readback[9]);
3113 ret = FALSE;
3114 }
3115 else
3116 {
3117 TRACE("Read back colors are 0x%08x and 0x%08x, assuming texture is filtered\n",
3118 readback[6], readback[9]);
3119 ret = TRUE;
3120 }
3121
3122 gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3123 gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
3124 gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
3125 gl_info->gl_ops.gl.p_glDeleteTextures(1, &buffer);
3126 gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
3127
3128 if (gl_info->gl_ops.gl.p_glGetError())
3129 {
3130 FIXME("Error during filtering test for format %x, returning no filtering\n", internal);
3131 ret = FALSE;
3132 }
3133
3134 return ret;
3135}
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
static BOOL color_match(DWORD c1, DWORD c2, BYTE max_diff)
Definition: utils.c:3025
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define GL_TEXTURE_WRAP_R
Definition: gl.h:1518
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
#define GL_LINEAR
Definition: gl.h:421
#define GL_NEAREST
Definition: gl.h:678
#define GL_PROJECTION
Definition: gl.h:246
#define GL_MODELVIEW
Definition: gl.h:245
#define GL_RGBA
Definition: gl.h:503
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_UNSIGNED_INT_8_8_8_8
Definition: gl.h:1494
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_LIGHTING
Definition: gl.h:310
GLuint buffer
Definition: glext.h:5915
#define memset(x, y, z)
Definition: compat.h:39
int ret

Referenced by init_format_filter_info().

◆ color_in_range()

static BOOL color_in_range ( const struct wined3d_color_key color_key,
DWORD  color 
)
static

Definition at line 890 of file utils.c.

891{
892 /* FIXME: Is this really how color keys are supposed to work? I think it
893 * makes more sense to compare the individual channels. */
894 return color >= color_key->color_space_low_value
895 && color <= color_key->color_space_high_value;
896}

Referenced by convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key(), convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key(), convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key(), convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key(), and convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key().

◆ color_match()

static BOOL color_match ( DWORD  c1,
DWORD  c2,
BYTE  max_diff 
)
static

Definition at line 3025 of file utils.c.

3026{
3027 if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
3028 c1 >>= 8; c2 >>= 8;
3029 if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
3030 c1 >>= 8; c2 >>= 8;
3031 if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
3032 c1 >>= 8; c2 >>= 8;
3033 if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
3034 return TRUE;
3035}
#define abs(i)
Definition: fconv.c:206

Referenced by check_filter().

◆ color_to_float()

static float color_to_float ( DWORD  color,
DWORD  size,
DWORD  offset 
)
static

Definition at line 5308 of file utils.c.

5309{
5310 DWORD mask = size < 32 ? (1u << size) - 1 : ~0u;
5311
5312 if (!size)
5313 return 1.0f;
5314
5315 color >>= offset;
5316 color &= mask;
5317
5318 return (float)color / (float)mask;
5319}
GLsizeiptr size
Definition: glext.h:5919
GLenum GLint GLuint mask
Definition: glext.h:6028
GLintptr offset
Definition: glext.h:5920
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
static float(__cdecl *square_half_float)(float x

Referenced by wined3d_format_get_float_color_key().

◆ compute_texture_matrix()

static void compute_texture_matrix ( const struct wined3d_gl_info gl_info,
const struct wined3d_matrix matrix,
DWORD  flags,
BOOL  calculated_coords,
BOOL  transformed,
enum wined3d_format_id  format_id,
BOOL  ffp_proj_control,
struct wined3d_matrix out_matrix 
)
static

Definition at line 4984 of file utils.c.

4987{
4988 struct wined3d_matrix mat;
4989
4990 if (flags == WINED3D_TTFF_DISABLE || flags == WINED3D_TTFF_COUNT1 || transformed)
4991 {
4992 get_identity_matrix(out_matrix);
4993 return;
4994 }
4995
4997 {
4998 ERR("Invalid texture transform flags: WINED3D_TTFF_COUNT1 | WINED3D_TTFF_PROJECTED.\n");
4999 return;
5000 }
5001
5002 mat = *matrix;
5003
5005 {
5006 if (!ffp_proj_control)
5007 {
5008 switch (flags & ~WINED3D_TTFF_PROJECTED)
5009 {
5011 mat._14 = mat._12;
5012 mat._24 = mat._22;
5013 mat._34 = mat._32;
5014 mat._44 = mat._42;
5015 mat._12 = mat._22 = mat._32 = mat._42 = 0.0f;
5016 break;
5018 mat._14 = mat._13;
5019 mat._24 = mat._23;
5020 mat._34 = mat._33;
5021 mat._44 = mat._43;
5022 mat._13 = mat._23 = mat._33 = mat._43 = 0.0f;
5023 break;
5024 }
5025 }
5026 }
5027 else
5028 {
5029 /* Under Direct3D the R/Z coord can be used for translation, under
5030 * OpenGL we use the Q coord instead. */
5031 if (!calculated_coords)
5032 {
5033 switch (format_id)
5034 {
5035 /* Direct3D passes the default 1.0 in the 2nd coord, while GL
5036 * passes it in the 4th. Swap 2nd and 4th coord. No need to
5037 * store the value of mat._41 in mat._21 because the input
5038 * value to the transformation will be 0, so the matrix value
5039 * is irrelevant. */
5041 mat._41 = mat._21;
5042 mat._42 = mat._22;
5043 mat._43 = mat._23;
5044 mat._44 = mat._24;
5045 break;
5046 /* See above, just 3rd and 4th coord. */
5048 mat._41 = mat._31;
5049 mat._42 = mat._32;
5050 mat._43 = mat._33;
5051 mat._44 = mat._34;
5052 break;
5053 case WINED3DFMT_R32G32B32_FLOAT: /* Opengl defaults match dx defaults */
5054 case WINED3DFMT_R32G32B32A32_FLOAT: /* No defaults apply, all app defined */
5055
5056 /* This is to prevent swapping the matrix lines and put the default 4th coord = 1.0
5057 * into a bad place. The division elimination below will apply to make sure the
5058 * 1.0 doesn't do anything bad. The caller will set this value if the stride is 0
5059 */
5060 case WINED3DFMT_UNKNOWN: /* No texture coords, 0/0/0/1 defaults are passed */
5061 break;
5062 default:
5063 FIXME("Unexpected fixed function texture coord input\n");
5064 }
5065 }
5066 if (!ffp_proj_control)
5067 {
5068 switch (flags & ~WINED3D_TTFF_PROJECTED)
5069 {
5070 /* case WINED3D_TTFF_COUNT1: Won't ever get here. */
5072 mat._13 = mat._23 = mat._33 = mat._43 = 0.0f;
5073 /* OpenGL divides the first 3 vertex coordinates by the 4th by
5074 * default, which is essentially the same as D3DTTFF_PROJECTED.
5075 * Make sure that the 4th coordinate evaluates to 1.0 to
5076 * eliminate that.
5077 *
5078 * If the fixed function pipeline is used, the 4th value
5079 * remains unused, so there is no danger in doing this. With
5080 * vertex shaders we have a problem. Should an application hit
5081 * that problem, the code here would have to check for pixel
5082 * shaders, and the shader has to undo the default GL divide.
5083 *
5084 * A more serious problem occurs if the application passes 4
5085 * coordinates in, and the 4th is != 1.0 (OpenGL default).
5086 * This would have to be fixed with immediate mode draws. */
5087 default:
5088 mat._14 = mat._24 = mat._34 = 0.0f; mat._44 = 1.0f;
5089 }
5090 }
5091 }
5092
5093 *out_matrix = mat;
5094}
void get_identity_matrix(struct wined3d_matrix *mat)
Definition: utils.c:4886
GLuint GLenum matrix
Definition: glext.h:9407
GLbitfield flags
Definition: glext.h:7161
static const MAT2 mat
Definition: font.c:66
static UINT format_id
Definition: clipboard.c:1343
@ WINED3DFMT_R32G32B32_FLOAT
Definition: wined3d.h:140
@ WINED3DFMT_UNKNOWN
Definition: wined3d.h:107
@ WINED3DFMT_R32G32B32A32_FLOAT
Definition: wined3d.h:136
@ WINED3D_TTFF_COUNT2
Definition: wined3d.h:601
@ WINED3D_TTFF_DISABLE
Definition: wined3d.h:599
@ WINED3D_TTFF_COUNT3
Definition: wined3d.h:602
@ WINED3D_TTFF_COUNT1
Definition: wined3d.h:600
@ WINED3D_TTFF_PROJECTED
Definition: wined3d.h:604

Referenced by get_texture_matrix().

◆ convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key()

static void convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 957 of file utils.c.

960{
961 const WORD *src_row;
962 unsigned int x, y;
963 WORD *dst_row;
964
965 for (y = 0; y < height; ++y)
966 {
967 src_row = (WORD *)&src[src_pitch * y];
968 dst_row = (WORD *)&dst[dst_pitch * y];
969 for (x = 0; x < width; ++x)
970 {
971 WORD src_color = src_row[x];
972 if (color_in_range(color_key, src_color))
973 dst_row[x] = src_color & ~0x8000;
974 else
975 dst_row[x] = src_color | 0x8000;
976 }
977 }
978}
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:890
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key()

static void convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 934 of file utils.c.

937{
938 const WORD *src_row;
939 unsigned int x, y;
940 WORD *dst_row;
941
942 for (y = 0; y < height; ++y)
943 {
944 src_row = (WORD *)&src[src_pitch * y];
945 dst_row = (WORD *)&dst[dst_pitch * y];
946 for (x = 0; x < width; ++x)
947 {
948 WORD src_color = src_row[x];
949 if (!color_in_range(color_key, src_color))
950 dst_row[x] = 0x8000u | ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu);
951 else
952 dst_row[x] = ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu);
953 }
954 }
955}

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key()

static void convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 980 of file utils.c.

983{
984 const BYTE *src_row;
985 unsigned int x, y;
986 DWORD *dst_row;
987
988 for (y = 0; y < height; ++y)
989 {
990 src_row = &src[src_pitch * y];
991 dst_row = (DWORD *)&dst[dst_pitch * y];
992 for (x = 0; x < width; ++x)
993 {
994 DWORD src_color = (src_row[x * 3 + 2] << 16) | (src_row[x * 3 + 1] << 8) | src_row[x * 3];
995 if (!color_in_range(color_key, src_color))
996 dst_row[x] = src_color | 0xff000000;
997 }
998 }
999}

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key()

static void convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 1024 of file utils.c.

1027{
1028 const DWORD *src_row;
1029 unsigned int x, y;
1030 DWORD *dst_row;
1031
1032 for (y = 0; y < height; ++y)
1033 {
1034 src_row = (DWORD *)&src[src_pitch * y];
1035 dst_row = (DWORD *)&dst[dst_pitch * y];
1036 for (x = 0; x < width; ++x)
1037 {
1038 DWORD src_color = src_row[x];
1039 if (color_in_range(color_key, src_color))
1040 src_color &= ~0xff000000;
1041 dst_row[x] = src_color;
1042 }
1043 }
1044}

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key()

static void convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 1001 of file utils.c.

1004{
1005 const DWORD *src_row;
1006 unsigned int x, y;
1007 DWORD *dst_row;
1008
1009 for (y = 0; y < height; ++y)
1010 {
1011 src_row = (DWORD *)&src[src_pitch * y];
1012 dst_row = (DWORD *)&dst[dst_pitch * y];
1013 for (x = 0; x < width; ++x)
1014 {
1015 DWORD src_color = src_row[x];
1016 if (color_in_range(color_key, src_color))
1017 dst_row[x] = src_color & ~0xff000000;
1018 else
1019 dst_row[x] = src_color | 0xff000000;
1020 }
1021 }
1022}

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_l4a4_unorm()

static void convert_l4a4_unorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 445 of file utils.c.

447{
448 /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not
449 * format+type combination to load it. Thus convert it to A8L8, then load it
450 * with A4L4 internal, but A8L8 format+type
451 */
452 unsigned int x, y, z;
453 const unsigned char *Source;
454 unsigned char *Dest;
455
456 for (z = 0; z < depth; z++)
457 {
458 for (y = 0; y < height; y++)
459 {
460 Source = src + z * src_slice_pitch + y * src_row_pitch;
461 Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
462 for (x = 0; x < width; x++ )
463 {
464 unsigned char color = (*Source++);
465 /* A */ Dest[1] = (color & 0xf0u) << 0;
466 /* L */ Dest[0] = (color & 0x0fu) << 4;
467 Dest += 2;
468 }
469 }
470 }
471}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLdouble GLdouble z
Definition: glext.h:5874
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169

◆ convert_p8_uint_b8g8r8a8_unorm()

static void convert_p8_uint_b8g8r8a8_unorm ( const BYTE src,
unsigned int  src_pitch,
BYTE dst,
unsigned int  dst_pitch,
unsigned int  width,
unsigned int  height,
const struct wined3d_palette palette,
const struct wined3d_color_key color_key 
)
static

Definition at line 898 of file utils.c.

901{
902 const BYTE *src_row;
903 unsigned int x, y;
904 DWORD *dst_row;
905
906 if (!palette)
907 {
908 /* FIXME: This should probably use the system palette. */
909 FIXME("P8 surface loaded without a palette.\n");
910
911 for (y = 0; y < height; ++y)
912 {
913 memset(&dst[dst_pitch * y], 0, width * 4);
914 }
915
916 return;
917 }
918
919 for (y = 0; y < height; ++y)
920 {
921 src_row = &src[src_pitch * y];
922 dst_row = (DWORD *)&dst[dst_pitch * y];
923 for (x = 0; x < width; ++x)
924 {
925 BYTE src_color = src_row[x];
926 dst_row[x] = 0xff000000
927 | (palette->colors[src_color].rgbRed << 16)
928 | (palette->colors[src_color].rgbGreen << 8)
929 | palette->colors[src_color].rgbBlue;
930 }
931 }
932}
static HPALETTE palette
Definition: clipboard.c:1345

Referenced by wined3d_format_get_color_key_conversion().

◆ convert_r16g16()

static void convert_r16g16 ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 724 of file utils.c.

726{
727 unsigned int x, y, z;
728 const WORD *Source;
729 WORD *Dest;
730
731 for (z = 0; z < depth; z++)
732 {
733 for (y = 0; y < height; y++)
734 {
735 Source = (const WORD *)(src + z * src_slice_pitch + y * src_row_pitch);
736 Dest = (WORD *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
737 for (x = 0; x < width; x++ )
738 {
739 WORD green = (*Source++);
740 WORD red = (*Source++);
741 Dest[0] = green;
742 Dest[1] = red;
743 /* Strictly speaking not correct for R16G16F, but it doesn't matter because the
744 * shader overwrites it anyway */
745 Dest[2] = 0xffff;
746 Dest += 3;
747 }
748 }
749 }
750}
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67

◆ convert_r16g16_snorm()

static void convert_r16g16_snorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 699 of file utils.c.

701{
702 unsigned int x, y, z;
703 const DWORD *Source;
704 unsigned short *Dest;
705
706 for (z = 0; z < depth; z++)
707 {
708 for (y = 0; y < height; y++)
709 {
710 Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
711 Dest = (unsigned short *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
712 for (x = 0; x < width; x++ )
713 {
714 const DWORD color = (*Source++);
715 /* B */ Dest[0] = 0xffff;
716 /* G */ Dest[1] = (color >> 16) + 32768; /* V */
717 /* R */ Dest[2] = (color & 0xffff) + 32768; /* U */
718 Dest += 3;
719 }
720 }
721 }
722}

◆ convert_r32g32_float()

static void convert_r32g32_float ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 752 of file utils.c.

754{
755 unsigned int x, y, z;
756 const float *Source;
757 float *Dest;
758
759 for (z = 0; z < depth; z++)
760 {
761 for (y = 0; y < height; y++)
762 {
763 Source = (const float *)(src + z * src_slice_pitch + y * src_row_pitch);
764 Dest = (float *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
765 for (x = 0; x < width; x++ )
766 {
767 float green = (*Source++);
768 float red = (*Source++);
769 Dest[0] = green;
770 Dest[1] = red;
771 Dest[2] = 1.0f;
772 Dest += 3;
773 }
774 }
775 }
776}

◆ convert_r5g5_snorm_l6_unorm()

static void convert_r5g5_snorm_l6_unorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 473 of file utils.c.

475{
476 unsigned int x, y, z;
477 unsigned char r_in, g_in, l_in;
478 const unsigned short *texel_in;
479 unsigned short *texel_out;
480
481 /* Emulating signed 5 bit values with unsigned 5 bit values has some precision problems by design:
482 * E.g. the signed input value 0 becomes 16. GL normalizes it to 16 / 31 = 0.516. We convert it
483 * back to a signed value by subtracting 0.5 and multiplying by 2.0. The resulting value is
484 * ((16 / 31) - 0.5) * 2.0 = 0.032, which is quite different from the intended result 0.000. */
485 for (z = 0; z < depth; z++)
486 {
487 for (y = 0; y < height; y++)
488 {
489 texel_out = (unsigned short *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
490 texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
491 for (x = 0; x < width; x++ )
492 {
493 l_in = (*texel_in & 0xfc00u) >> 10;
494 g_in = (*texel_in & 0x03e0u) >> 5;
495 r_in = *texel_in & 0x001fu;
496
497 *texel_out = ((r_in + 16) << 11) | (l_in << 5) | (g_in + 16);
498 texel_out++;
499 texel_in++;
500 }
501 }
502 }
503}
static struct stream g_in
Definition: tcp.c:73

◆ convert_r5g5_snorm_l6_unorm_ext()

static void convert_r5g5_snorm_l6_unorm_ext ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 505 of file utils.c.

507{
508 unsigned int x, y, z;
509 unsigned char *texel_out, r_out, g_out, r_in, g_in, l_in;
510 const unsigned short *texel_in;
511
512 for (z = 0; z < depth; z++)
513 {
514 for (y = 0; y < height; y++)
515 {
516 texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
517 texel_out = dst + z * dst_slice_pitch + y * dst_row_pitch;
518 for (x = 0; x < width; x++ )
519 {
520 l_in = (*texel_in & 0xfc00u) >> 10;
521 g_in = (*texel_in & 0x03e0u) >> 5;
522 r_in = *texel_in & 0x001fu;
523
524 r_out = r_in << 3;
525 if (!(r_in & 0x10)) /* r > 0 */
526 r_out |= r_in >> 1;
527
528 g_out = g_in << 3;
529 if (!(g_in & 0x10)) /* g > 0 */
530 g_out |= g_in >> 1;
531
532 texel_out[0] = r_out;
533 texel_out[1] = g_out;
534 texel_out[2] = l_in << 1 | l_in >> 5;
535 texel_out[3] = 0;
536
537 texel_out += 4;
538 texel_in++;
539 }
540 }
541 }
542}
static struct stream g_out[STREAM_COUNT]
Definition: tcp.c:74

◆ convert_r5g5_snorm_l6_unorm_nv()

static void convert_r5g5_snorm_l6_unorm_nv ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 544 of file utils.c.

546{
547 unsigned int x, y, z;
548 unsigned char *texel_out, ds_out, dt_out, r_in, g_in, l_in;
549 const unsigned short *texel_in;
550
551 /* This makes the gl surface bigger(24 bit instead of 16), but it works with
552 * fixed function and shaders without further conversion once the surface is
553 * loaded.
554 *
555 * The difference between this function and convert_r5g5_snorm_l6_unorm_ext
556 * is that convert_r5g5_snorm_l6_unorm_ext creates a 32 bit XRGB texture and
557 * this function creates a 24 bit DSDT_MAG texture. Trying to load a DSDT_MAG
558 * internal with a 32 bit DSDT_MAG_INTENSITY or DSDT_MAG_VIB format fails. */
559 for (z = 0; z < depth; z++)
560 {
561 for (y = 0; y < height; y++)
562 {
563 texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
564 texel_out = dst + z * dst_slice_pitch + y * dst_row_pitch;
565 for (x = 0; x < width; x++ )
566 {
567 l_in = (*texel_in & 0xfc00u) >> 10;
568 g_in = (*texel_in & 0x03e0u) >> 5;
569 r_in = *texel_in & 0x001fu;
570
571 ds_out = r_in << 3;
572 if (!(r_in & 0x10)) /* r > 0 */
573 ds_out |= r_in >> 1;
574
575 dt_out = g_in << 3;
576 if (!(g_in & 0x10)) /* g > 0 */
577 dt_out |= g_in >> 1;
578
579 texel_out[0] = ds_out;
580 texel_out[1] = dt_out;
581 texel_out[2] = l_in << 1 | l_in >> 5;
582
583 texel_out += 3;
584 texel_in++;
585 }
586 }
587 }
588}

◆ convert_r8g8_snorm()

static void convert_r8g8_snorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 590 of file utils.c.

592{
593 unsigned int x, y, z;
594 const short *Source;
595 unsigned char *Dest;
596
597 for (z = 0; z < depth; z++)
598 {
599 for (y = 0; y < height; y++)
600 {
601 Source = (const short *)(src + z * src_slice_pitch + y * src_row_pitch);
602 Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
603 for (x = 0; x < width; x++ )
604 {
605 const short color = (*Source++);
606 /* B */ Dest[0] = 0xff;
607 /* G */ Dest[1] = (color >> 8) + 128; /* V */
608 /* R */ Dest[2] = (color & 0xff) + 128; /* U */
609 Dest += 3;
610 }
611 }
612 }
613}

◆ convert_r8g8_snorm_l8x8_unorm()

static void convert_r8g8_snorm_l8x8_unorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 615 of file utils.c.

617{
618 unsigned int x, y, z;
619 const DWORD *Source;
620 unsigned char *Dest;
621
622 /* Doesn't work correctly with the fixed function pipeline, but can work in
623 * shaders if the shader is adjusted. (There's no use for this format in gl's
624 * standard fixed function pipeline anyway).
625 */
626 for (z = 0; z < depth; z++)
627 {
628 for (y = 0; y < height; y++)
629 {
630 Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
631 Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
632 for (x = 0; x < width; x++ )
633 {
634 LONG color = (*Source++);
635 /* B */ Dest[0] = ((color >> 16) & 0xff); /* L */
636 /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
637 /* R */ Dest[2] = (color & 0xff) + 128; /* U */
638 Dest += 4;
639 }
640 }
641 }
642}
long LONG
Definition: pedump.c:60

◆ convert_r8g8_snorm_l8x8_unorm_nv()

static void convert_r8g8_snorm_l8x8_unorm_nv ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 644 of file utils.c.

646{
647 unsigned int x, y, z;
648 const DWORD *Source;
649 unsigned char *Dest;
650
651 /* This implementation works with the fixed function pipeline and shaders
652 * without further modification after converting the surface.
653 */
654 for (z = 0; z < depth; z++)
655 {
656 for (y = 0; y < height; y++)
657 {
658 Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
659 Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
660 for (x = 0; x < width; x++ )
661 {
662 LONG color = (*Source++);
663 /* L */ Dest[2] = ((color >> 16) & 0xff); /* L */
664 /* V */ Dest[1] = ((color >> 8 ) & 0xff); /* V */
665 /* U */ Dest[0] = (color & 0xff); /* U */
666 /* I */ Dest[3] = 255; /* X */
667 Dest += 4;
668 }
669 }
670 }
671}

◆ convert_r8g8b8a8_snorm()

static void convert_r8g8b8a8_snorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 673 of file utils.c.

675{
676 unsigned int x, y, z;
677 const DWORD *Source;
678 unsigned char *Dest;
679
680 for (z = 0; z < depth; z++)
681 {
682 for (y = 0; y < height; y++)
683 {
684 Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
685 Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
686 for (x = 0; x < width; x++ )
687 {
688 LONG color = (*Source++);
689 /* B */ Dest[0] = ((color >> 16) & 0xff) + 128; /* W */
690 /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
691 /* R */ Dest[2] = (color & 0xff) + 128; /* U */
692 /* A */ Dest[3] = ((color >> 24) & 0xff) + 128; /* Q */
693 Dest += 4;
694 }
695 }
696 }
697}

◆ convert_s1_uint_d15_unorm()

static void convert_s1_uint_d15_unorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 778 of file utils.c.

780{
781 unsigned int x, y, z;
782
783 for (z = 0; z < depth; z++)
784 {
785 for (y = 0; y < height; ++y)
786 {
787 const WORD *source = (const WORD *)(src + z * src_slice_pitch + y * src_row_pitch);
788 DWORD *dest = (DWORD *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
789
790 for (x = 0; x < width; ++x)
791 {
792 /* The depth data is normalized, so needs to be scaled,
793 * the stencil data isn't. Scale depth data by
794 * (2^24-1)/(2^15-1) ~~ (2^9 + 2^-6). */
795 WORD d15 = source[x] >> 1;
796 DWORD d24 = (d15 << 9) + (d15 >> 6);
797 dest[x] = (d24 << 8) | (source[x] & 0x1);
798 }
799 }
800 }
801}
static char * dest
Definition: rtl.c:135

◆ convert_s4x4_uint_d24_unorm()

static void convert_s4x4_uint_d24_unorm ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 803 of file utils.c.

805{
806 unsigned int x, y, z;
807
808 for (z = 0; z < depth; z++)
809 {
810 for (y = 0; y < height; ++y)
811 {
812 const DWORD *source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
813 DWORD *dest = (DWORD *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
814
815 for (x = 0; x < width; ++x)
816 {
817 /* Just need to clear out the X4 part. */
818 dest[x] = source[x] & ~0xf0;
819 }
820 }
821 }
822}

◆ convert_s8_uint_d24_float()

static void convert_s8_uint_d24_float ( const BYTE src,
BYTE dst,
UINT  src_row_pitch,
UINT  src_slice_pitch,
UINT  dst_row_pitch,
UINT  dst_slice_pitch,
UINT  width,
UINT  height,
UINT  depth 
)
static

Definition at line 824 of file utils.c.

826{
827 unsigned int x, y, z;
828
829 for (z = 0; z < depth; z++)
830 {
831 for (y = 0; y < height; ++y)
832 {
833 const DWORD *source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
834 float *dest_f = (float *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
835 DWORD *dest_s = (DWORD *)dest_f;
836
837 for (x = 0; x < width; ++x)
838 {
839 dest_f[x * 2] = float_24_to_32((source[x] & 0xffffff00u) >> 8);
840 dest_s[x * 2 + 1] = source[x] & 0xff;
841 }
842 }
843 }
844}
static float float_24_to_32(DWORD in)

◆ copy_format()

static void copy_format ( struct wined3d_format dst_format,
const struct wined3d_format src_format 
)
static

Definition at line 1780 of file utils.c.

1781{
1782 enum wined3d_format_id id = dst_format->id;
1783 *dst_format = *src_format;
1784 dst_format->id = id;
1785}
enum wined3d_format_id id
Definition: utils.c:40
static const char * dst_format
Definition: dib.c:1133
wined3d_format_id
Definition: wined3d.h:106

Referenced by init_format_texture_info(), and init_typeless_formats().

◆ create_and_bind_fbo_attachment()

static void create_and_bind_fbo_attachment ( const struct wined3d_gl_info gl_info,
unsigned int  flags,
enum wined3d_gl_resource_type  d3d_type,
GLuint object,
GLenum  internal,
GLenum  format,
GLenum  type 
)
static

Definition at line 2003 of file utils.c.

2005{
2006 GLenum attach_type = flags & WINED3DFMT_FLAG_DEPTH ?
2008
2009 switch (d3d_type)
2010 {
2012 gl_info->gl_ops.gl.p_glGenTextures(1, object);
2013 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, *object);
2014 gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, internal, 16, 0, format, type, NULL);
2015 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2016 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2017
2018 gl_info->fbo_ops.glFramebufferTexture1D(GL_FRAMEBUFFER, attach_type, GL_TEXTURE_1D,
2019 *object, 0);
2021 gl_info->fbo_ops.glFramebufferTexture1D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_1D,
2022 *object, 0);
2023 break;
2024
2027 gl_info->gl_ops.gl.p_glGenTextures(1, object);
2028 gl_info->gl_ops.gl.p_glBindTexture(wined3d_gl_type_to_enum(d3d_type), *object);
2029 gl_info->gl_ops.gl.p_glTexImage2D(wined3d_gl_type_to_enum(d3d_type), 0, internal, 16, 16, 0,
2030 format, type, NULL);
2031 gl_info->gl_ops.gl.p_glTexParameteri(wined3d_gl_type_to_enum(d3d_type), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2032 gl_info->gl_ops.gl.p_glTexParameteri(wined3d_gl_type_to_enum(d3d_type), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2033
2034 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, attach_type,
2035 wined3d_gl_type_to_enum(d3d_type), *object, 0);
2037 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2038 wined3d_gl_type_to_enum(d3d_type), *object, 0);
2039 break;
2040
2042 gl_info->gl_ops.gl.p_glGenTextures(1, object);
2043 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, *object);
2045 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2046 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2047
2048 gl_info->fbo_ops.glFramebufferTexture3D(GL_FRAMEBUFFER, attach_type,
2049 GL_TEXTURE_3D, *object, 0, 0);
2051 gl_info->fbo_ops.glFramebufferTexture3D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2052 GL_TEXTURE_3D, *object, 0, 0);
2053 break;
2054
2056 gl_info->gl_ops.gl.p_glGenTextures(1, object);
2057 gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, *object);
2058 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, internal, 16, 16, 0,
2059 format, type, NULL);
2060 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 0, internal, 16, 16, 0,
2061 format, type, NULL);
2062 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, 0, internal, 16, 16, 0,
2063 format, type, NULL);
2064 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, 0, internal, 16, 16, 0,
2065 format, type, NULL);
2066 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, 0, internal, 16, 16, 0,
2067 format, type, NULL);
2068 gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, 0, internal, 16, 16, 0,
2069 format, type, NULL);
2070 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2071 gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2072
2073 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, attach_type,
2076 gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2078 break;
2079
2081 gl_info->fbo_ops.glGenRenderbuffers(1, object);
2082 gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, *object);
2083 gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, internal, 16, 16);
2084 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, attach_type, GL_RENDERBUFFER,
2085 *object);
2087 gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2088 *object);
2089 break;
2090
2093 break;
2094 }
2095
2096 /* Ideally we'd skip all formats already known not to work on textures
2097 * by checking for WINED3DFMT_FLAG_TEXTURE here. However, we want to
2098 * know if we can attach WINED3DFMT_P8_UINT textures to FBOs, and this
2099 * format never has WINED3DFMT_FLAG_TEXTURE set. Instead, swallow GL
2100 * errors generated by invalid formats. */
2101 while (gl_info->gl_ops.gl.p_glGetError());
2102}
#define GL_TEXTURE_3D
Definition: gl.h:1515
GLAPI void GLAPIENTRY glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
Definition: glext.h:1237
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
Definition: glext.h:1234
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
Definition: glext.h:1235
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
Definition: glext.h:1236
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
Definition: glext.h:1233
#define GL_EXTCALL(f)

Referenced by check_fbo_compat().

◆ debug_append()

static void debug_append ( struct debug_buffer buffer,
const char str,
const char separator 
)
static

Definition at line 4182 of file utils.c.

4183{
4184 int size;
4185
4186 if (!separator || buffer->ptr == buffer->str)
4187 separator = "";
4188 size = snprintf(buffer->ptr, buffer->size, "%s%s", separator, str);
4189 if (size == -1 || size >= buffer->size)
4190 {
4191 buffer->size = 0;
4192 strcpy(&buffer->str[ARRAY_SIZE(buffer->str) - 4], "...");
4193 return;
4194 }
4195
4196 buffer->ptr += size;
4197 buffer->size -= size;
4198}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static const WCHAR separator[]
Definition: asmname.c:65
const WCHAR * str
#define snprintf
Definition: wintirpc.h:48

◆ debug_box()

const char * debug_box ( const struct wined3d_box box)

Definition at line 3939 of file utils.c.

3940{
3941 if (!box)
3942 return "(null)";
3943 return wine_dbg_sprintf("(%u, %u, %u)-(%u, %u, %u)",
3944 box->left, box->top, box->front,
3945 box->right, box->bottom, box->back);
3946}
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
Definition: palette.c:468

Referenced by surface_cpu_blt(), surface_cpu_blt_colour_fill(), texture3d_upload_data(), texture_resource_sub_resource_map(), wined3d_cs_exec_blt_sub_resource(), wined3d_device_copy_sub_resource_region(), wined3d_device_update_sub_resource(), wined3d_resource_map(), wined3d_resource_update_info(), wined3d_texture_add_dirty_region(), and wined3d_texture_check_box_dimensions().

◆ debug_color()

const char * debug_color ( const struct wined3d_color color)

◆ debug_complex_fixup()

static const char * debug_complex_fixup ( enum complex_fixup  fixup)
static

Definition at line 4834 of file utils.c.

4835{
4836 switch(fixup)
4837 {
4838#define WINED3D_TO_STR(x) case x: return #x
4844#undef WINED3D_TO_STR
4845 default:
4846 FIXME("Unrecognized complex fixup %#x\n", fixup);
4847 return "unrecognized";
4848 }
4849}
#define WINED3D_TO_STR(x)

Referenced by dump_color_fixup_desc().

◆ debug_d3ddeclmethod()

const char * debug_d3ddeclmethod ( enum wined3d_decl_method  method)

Definition at line 4270 of file utils.c.

4271{
4272 switch (method)
4273 {
4274#define WINED3DDECLMETHOD_TO_STR(u) case u: return #u
4282#undef WINED3DDECLMETHOD_TO_STR
4283 default:
4284 FIXME("Unrecognized declaration method %#x.\n", method);
4285 return "unrecognized";
4286 }
4287}
#define WINED3DDECLMETHOD_TO_STR(u)
method
Definition: dragdrop.c:54
@ WINED3D_DECL_METHOD_LOOKUP
Definition: wined3d.h:780
@ WINED3D_DECL_METHOD_LOOKUP_PRESAMPLED
Definition: wined3d.h:781
@ WINED3D_DECL_METHOD_PARTIAL_V
Definition: wined3d.h:777
@ WINED3D_DECL_METHOD_CROSS_UV
Definition: wined3d.h:778
@ WINED3D_DECL_METHOD_UV
Definition: wined3d.h:779
@ WINED3D_DECL_METHOD_PARTIAL_U
Definition: wined3d.h:776
@ WINED3D_DECL_METHOD_DEFAULT
Definition: wined3d.h:775

Referenced by dump_wined3d_vertex_element().

◆ debug_d3ddeclusage()

const char * debug_d3ddeclusage ( enum wined3d_decl_usage  usage)

Definition at line 4289 of file utils.c.

4290{
4291 switch (usage)
4292 {
4293#define WINED3DDECLUSAGE_TO_STR(u) case u: return #u
4308#undef WINED3DDECLUSAGE_TO_STR
4309 default:
4310 FIXME("Unrecognized %u declaration usage!\n", usage);
4311 return "unrecognized";
4312 }
4313}
#define WINED3DDECLUSAGE_TO_STR(u)
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
@ WINED3D_DECL_USAGE_DEPTH
Definition: wined3d.h:798
@ WINED3D_DECL_USAGE_BLEND_INDICES
Definition: wined3d.h:788
@ WINED3D_DECL_USAGE_TESS_FACTOR
Definition: wined3d.h:794
@ WINED3D_DECL_USAGE_NORMAL
Definition: wined3d.h:789
@ WINED3D_DECL_USAGE_PSIZE
Definition: wined3d.h:790
@ WINED3D_DECL_USAGE_BLEND_WEIGHT
Definition: wined3d.h:787
@ WINED3D_DECL_USAGE_SAMPLE
Definition: wined3d.h:799
@ WINED3D_DECL_USAGE_POSITION
Definition: wined3d.h:786
@ WINED3D_DECL_USAGE_BINORMAL
Definition: wined3d.h:793
@ WINED3D_DECL_USAGE_COLOR
Definition: wined3d.h:796
@ WINED3D_DECL_USAGE_POSITIONT
Definition: wined3d.h:795
@ WINED3D_DECL_USAGE_TEXCOORD
Definition: wined3d.h:791
@ WINED3D_DECL_USAGE_TANGENT
Definition: wined3d.h:792
@ WINED3D_DECL_USAGE_FOG
Definition: wined3d.h:797

Referenced by dump_wined3d_vertex_element(), fixed_get_input(), and wined3d_stream_info_from_declaration().

◆ debug_d3ddevicetype()

const char * debug_d3ddevicetype ( enum wined3d_device_type  device_type)

Definition at line 4153 of file utils.c.

4154{
4155 switch (device_type)
4156 {
4157#define DEVTYPE_TO_STR(dev) case dev: return #dev
4161#undef DEVTYPE_TO_STR
4162 default:
4163 FIXME("Unrecognized device type %#x.\n", device_type);
4164 return "unrecognized";
4165 }
4166}
device_type
#define DEVTYPE_TO_STR(dev)
@ WINED3D_DEVICE_TYPE_SW
Definition: wined3d.h:89
@ WINED3D_DEVICE_TYPE_HAL
Definition: wined3d.h:87
@ WINED3D_DEVICE_TYPE_REF
Definition: wined3d.h:88

Referenced by wined3d_check_depth_stencil_match(), wined3d_check_device_format(), wined3d_check_device_format_conversion(), wined3d_check_device_multisample_type(), wined3d_check_device_type(), and wined3d_get_device_caps().

◆ debug_d3dformat()

const char * debug_d3dformat ( enum wined3d_format_id  format_id)

Definition at line 3980 of file utils.c.

3981{
3982 switch (format_id)
3983 {
3984#define FMT_TO_STR(format_id) case format_id: return #format_id
4135#undef FMT_TO_STR
4136 default:
4137 {
4138 char fourcc[5];
4139 fourcc[0] = (char)(format_id);
4140 fourcc[1] = (char)(format_id >> 8);
4141 fourcc[2] = (char)(format_id >> 16);
4142 fourcc[3] = (char)(format_id >> 24);
4143 fourcc[4] = 0;
4144 if (isprint(fourcc[0]) && isprint(fourcc[1]) && isprint(fourcc[2]) && isprint(fourcc[3]))
4145 FIXME("Unrecognized %#x (as fourcc: %s) WINED3DFORMAT!\n", format_id, fourcc);
4146 else
4147 FIXME("Unrecognized %#x WINED3DFORMAT!\n", format_id);
4148 }
4149 return "unrecognized";
4150 }
4151}
#define isprint(c)
Definition: acclib.h:73
#define FMT_TO_STR(format_id)
unsigned char
Definition: typeof.h:29
@ WINED3DFMT_R32G32B32_TYPELESS
Definition: wined3d.h:139
@ WINED3DFMT_R8_TYPELESS
Definition: wined3d.h:196
@ WINED3DFMT_B2G3R3_UNORM
Definition: wined3d.h:111
@ WINED3DFMT_R32G32B32_SINT
Definition: wined3d.h:142
@ WINED3DFMT_R8G8_UNORM
Definition: wined3d.h:185
@ WINED3DFMT_BC7_TYPELESS
Definition: wined3d.h:232
@ WINED3DFMT_BC7_UNORM_SRGB
Definition: wined3d.h:234
@ WINED3DFMT_R32G32_SINT
Definition: wined3d.h:152
@ WINED3DFMT_X24_TYPELESS_G8_UINT
Definition: wined3d.h:183
@ WINED3DFMT_B4G4R4A4_UNORM
Definition: wined3d.h:110
@ WINED3DFMT_R16G16_UINT
Definition: wined3d.h:172
@ WINED3DFMT_R8G8_TYPELESS
Definition: wined3d.h:184
@ WINED3DFMT_R10G10B10X2_UINT
Definition: wined3d.h:124
@ WINED3DFMT_X8D24_UNORM
Definition: wined3d.h:130
@ WINED3DFMT_R32_SINT
Definition: wined3d.h:179
@ WINED3DFMT_D32_FLOAT
Definition: wined3d.h:176
@ WINED3DFMT_R10G10B10A2_UNORM
Definition: wined3d.h:158
@ WINED3DFMT_R8_UINT
Definition: wined3d.h:198
@ WINED3DFMT_R8G8_SNORM_Cx
Definition: wined3d.h:134
@ WINED3DFMT_R16_UNORM
Definition: wined3d.h:192
@ WINED3DFMT_R24G8_TYPELESS
Definition: wined3d.h:180
@ WINED3DFMT_R10G10B10A2_TYPELESS
Definition: wined3d.h:157
@ WINED3DFMT_R32G32_UINT
Definition: wined3d.h:151
@ WINED3DFMT_R32G32B32_UINT
Definition: wined3d.h:141
@ WINED3DFMT_BC4_TYPELESS
Definition: wined3d.h:215
@ WINED3DFMT_R8_UNORM
Definition: wined3d.h:197
@ WINED3DFMT_S8_UINT_D24_FLOAT
Definition: wined3d.h:133
@ WINED3DFMT_R10G10B10_XR_BIAS_A2_UNORM
Definition: wined3d.h:161
@ WINED3DFMT_R16_TYPELESS
Definition: wined3d.h:189
@ WINED3DFMT_R16G16B16A16_SINT
Definition: wined3d.h:148
@ WINED3DFMT_D16_LOCKABLE
Definition: wined3d.h:127
@ WINED3DFMT_R10G11B11_SNORM
Definition: wined3d.h:123
@ WINED3DFMT_S1_UINT_D15_UNORM
Definition: wined3d.h:129
@ WINED3DFMT_R16_SINT
Definition: wined3d.h:195
@ WINED3DFMT_B2G3R3A8_UNORM
Definition: wined3d.h:112
@ WINED3DFMT_R8G8_B8G8_UNORM
Definition: wined3d.h:204
@ WINED3DFMT_B8G8R8X8_UNORM
Definition: wined3d.h:224
@ WINED3DFMT_R32_FLOAT_X8X24_TYPELESS
Definition: wined3d.h:155
@ WINED3DFMT_R8G8B8X8_UNORM
Definition: wined3d.h:114
@ WINED3DFMT_B5G5R5X1_UNORM
Definition: wined3d.h:109
@ WINED3DFMT_B10G10R10A2_UNORM
Definition: wined3d.h:115
@ WINED3DFMT_D16_UNORM
Definition: wined3d.h:191
@ WINED3DFMT_NVHS
Definition: wined3d.h:252
@ WINED3DFMT_R8G8B8A8_TYPELESS
Definition: wined3d.h:163
@ WINED3DFMT_R8G8_UINT
Definition: wined3d.h:186
@ WINED3DFMT_BC7_UNORM
Definition: wined3d.h:233
@ WINED3DFMT_B8G8R8_UNORM
Definition: wined3d.h:108
@ WINED3DFMT_R8G8B8A8_UNORM_SRGB
Definition: wined3d.h:165
@ WINED3DFMT_R9G9B9E5_SHAREDEXP
Definition: wined3d.h:203
@ WINED3DFMT_B8G8R8X8_TYPELESS
Definition: wined3d.h:227
@ WINED3DFMT_R32_UINT
Definition: wined3d.h:178
@ WINED3DFMT_B5G5R5A1_UNORM
Definition: wined3d.h:222
@ WINED3DFMT_R10G10B10_SNORM_A2_UNORM
Definition: wined3d.h:126
@ WINED3DFMT_D32_UNORM
Definition: wined3d.h:128
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:164
@ WINED3DFMT_R10G10B10A2_UINT
Definition: wined3d.h:159
@ WINED3DFMT_G8R8_G8B8_UNORM
Definition: wined3d.h:205
@ WINED3DFMT_R32G32B32A32_UINT
Definition: wined3d.h:137
@ WINED3DFMT_BC6H_UF16
Definition: wined3d.h:230
@ WINED3DFMT_R16G16B16A16_TYPELESS
Definition: wined3d.h:143
@ WINED3DFMT_R10G10B10A2_SNORM
Definition: wined3d.h:160
@ WINED3DFMT_R24_UNORM_X8_TYPELESS
Definition: wined3d.h:182
@ WINED3DFMT_R16
Definition: wined3d.h:256
@ WINED3DFMT_D32_FLOAT_S8X24_UINT
Definition: wined3d.h:154
@ WINED3DFMT_NVHU
Definition: wined3d.h:251
@ WINED3DFMT_X32_TYPELESS_G8X24_UINT
Definition: wined3d.h:156
@ WINED3DFMT_B5G6R5_UNORM
Definition: wined3d.h:221
@ WINED3DFMT_R16G16B16A16_UINT
Definition: wined3d.h:146
@ WINED3DFMT_S4X4_UINT_D24_UNORM
Definition: wined3d.h:131
@ WINED3DFMT_BC1_TYPELESS
Definition: wined3d.h:206
@ WINED3DFMT_B8G8R8X8_UNORM_SRGB
Definition: wined3d.h:228
@ WINED3DFMT_B8G8R8A8_TYPELESS
Definition: wined3d.h:225
@ WINED3DFMT_BC3_TYPELESS
Definition: wined3d.h:212
@ WINED3DFMT_R16G16_TYPELESS
Definition: wined3d.h:169
@ WINED3DFMT_R8_SNORM
Definition: wined3d.h:199
@ WINED3DFMT_G8R8_G8B8
Definition: wined3d.h:245
@ WINED3DFMT_R8G8B8A8_UINT
Definition: wined3d.h:166
@ WINED3DFMT_R16_SNORM
Definition: wined3d.h:194
@ WINED3DFMT_BC6H_TYPELESS
Definition: wined3d.h:229
@ WINED3DFMT_R32G32B32A32_TYPELESS
Definition: wined3d.h:135
@ WINED3DFMT_R32_TYPELESS
Definition: wined3d.h:175
@ WINED3DFMT_R32G8X24_TYPELESS
Definition: wined3d.h:153
@ WINED3DFMT_R16_UINT
Definition: wined3d.h:193
@ WINED3DFMT_R8_SINT
Definition: wined3d.h:200
@ WINED3DFMT_BC5_TYPELESS
Definition: wined3d.h:218
@ WINED3DFMT_R8G8_SINT
Definition: wined3d.h:188
@ WINED3DFMT_R32G32B32A32_SINT
Definition: wined3d.h:138
@ WINED3DFMT_R8G8B8A8_SINT
Definition: wined3d.h:168
@ WINED3DFMT_R10G10B10X2_SNORM
Definition: wined3d.h:125
@ WINED3DFMT_R1_UNORM
Definition: wined3d.h:202
@ WINED3DFMT_R11G11B10_FLOAT
Definition: wined3d.h:162
@ WINED3DFMT_B8G8R8A8_UNORM_SRGB
Definition: wined3d.h:226
@ WINED3DFMT_BC2_TYPELESS
Definition: wined3d.h:209
@ WINED3DFMT_R8G8_B8G8
Definition: wined3d.h:246
@ WINED3DFMT_BC6H_SF16
Definition: wined3d.h:231
@ WINED3DFMT_B4G4R4X4_UNORM
Definition: wined3d.h:113
@ WINED3DFMT_MULTI2_ARGB8
Definition: wined3d.h:244
@ WINED3DFMT_AL16
Definition: wined3d.h:257
@ WINED3DFMT_D24_UNORM_S8_UINT
Definition: wined3d.h:181
@ WINED3DFMT_P8_UINT_A8_UNORM
Definition: wined3d.h:116
@ WINED3DFMT_R16G16B16A16_SNORM
Definition: wined3d.h:147
@ WINED3DFMT_R16G16_SINT
Definition: wined3d.h:174
@ WINED3DFMT_R32G32_TYPELESS
Definition: wined3d.h:149

Referenced by buffer_check_attribute(), buffer_init(), buffer_process_converted_attribute(), check_fbo_compat(), CheckRenderTargetCapability(), context_choose_pixel_format(), context_find_fbo_entry(), cpu_blitter_clear(), draw_primitive_immediate_mode(), dump_wined3d_vertex_element(), get_format_internal(), init_format_depth_bias_scale(), init_format_fbo_compat_info(), init_format_filter_info(), init_format_vertex_info(), query_format_flag(), query_view_class(), resource_init(), state_depthbias(), surface_convert_format(), surface_cpu_blt(), surface_cpu_blt_colour_fill(), surface_cpu_blt_compressed(), surface_depth_blt_fbo(), surface_download_data(), swapchain_init(), texture1d_download_data(), texture2d_create_dc(), texture2d_prepare_texture(), texture3d_download_data(), validate_resource_view(), vertexdeclaration_init(), wined3d_calculate_format_pitch(), wined3d_check_depth_stencil_match(), wined3d_check_device_format(), wined3d_check_device_format_conversion(), wined3d_check_device_multisample_type(), wined3d_check_device_type(), wined3d_device_copy_resource(), wined3d_device_copy_sub_resource_region(), wined3d_device_reset(), wined3d_device_resolve_sub_resource(), wined3d_device_set_cursor_properties(), wined3d_device_set_index_buffer(), wined3d_dxt1_decode(), wined3d_dxt1_encode(), wined3d_dxt3_decode(), wined3d_dxt3_encode(), wined3d_dxt5_decode(), wined3d_dxt5_encode(), wined3d_enum_adapter_modes(), wined3d_find_closest_matching_adapter_mode(), wined3d_format_convert_from_float(), wined3d_format_get_color_key_conversion(), wined3d_format_get_float_color_key(), wined3d_get_adapter_display_mode(), wined3d_get_adapter_mode_count(), wined3d_get_format(), wined3d_render_target_view_cs_init(), wined3d_set_adapter_display_mode(), wined3d_shader_resource_view_cs_init(), wined3d_stream_info_from_declaration(), wined3d_surface_upload_data(), wined3d_swapchain_cs_init(), wined3d_swapchain_get_display_mode(), wined3d_swapchain_resize_buffers(), wined3d_texture_init(), wined3d_texture_update_desc(), and wined3d_unordered_access_view_clear_uint().

◆ debug_d3dinput_classification()

const char * debug_d3dinput_classification ( enum wined3d_input_classification  classification)

Definition at line 4315 of file utils.c.

4316{
4317 switch (classification)
4318 {
4319#define WINED3D_TO_STR(x) case x: return #x
4322#undef WINED3D_TO_STR
4323 default:
4324 FIXME("Unrecognized input classification %#x.\n", classification);
4325 return "unrecognized";
4326 }
4327}
@ WINED3D_INPUT_PER_INSTANCE_DATA
Definition: wined3d.h:1786
@ WINED3D_INPUT_PER_VERTEX_DATA
Definition: wined3d.h:1785

Referenced by dump_wined3d_vertex_element(), and wined3d_stream_info_from_declaration().

◆ debug_d3dprimitivetype()

const char * debug_d3dprimitivetype ( enum wined3d_primitive_type  primitive_type)

Definition at line 4346 of file utils.c.

4347{
4348 switch (primitive_type)
4349 {
4350#define PRIM_TO_STR(prim) case prim: return #prim
4363#undef PRIM_TO_STR
4364 default:
4365 FIXME("Unrecognized primitive type %#x.\n", primitive_type);
4366 return "unrecognized";
4367 }
4368}
#define PRIM_TO_STR(prim)
@ WINED3D_PT_LINESTRIP_ADJ
Definition: wined3d.h:79
@ WINED3D_PT_LINELIST
Definition: wined3d.h:73
@ WINED3D_PT_UNDEFINED
Definition: wined3d.h:71
@ WINED3D_PT_PATCH
Definition: wined3d.h:82
@ WINED3D_PT_POINTLIST
Definition: wined3d.h:72
@ WINED3D_PT_TRIANGLELIST_ADJ
Definition: wined3d.h:80
@ WINED3D_PT_LINELIST_ADJ
Definition: wined3d.h:78
@ WINED3D_PT_TRIANGLESTRIP_ADJ
Definition: wined3d.h:81
@ WINED3D_PT_TRIANGLESTRIP
Definition: wined3d.h:76
@ WINED3D_PT_LINESTRIP
Definition: wined3d.h:74
@ WINED3D_PT_TRIANGLELIST
Definition: wined3d.h:75
@ WINED3D_PT_TRIANGLEFAN
Definition: wined3d.h:77

Referenced by d3d_primitive_type_from_gl(), gl_primitive_type_from_d3d(), glsl_primitive_type_from_d3d(), wined3d_device_get_primitive_type(), and wined3d_device_set_primitive_type().

◆ debug_d3drenderstate()

const char * debug_d3drenderstate ( enum wined3d_render_state  state)

Definition at line 4370 of file utils.c.

4371{
4372 switch (state)
4373 {
4374#define D3DSTATE_TO_STR(u) case u: return #u
4470