ReactOS  0.4.12-dev-945-g5a2911d
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_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_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_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_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_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_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 (   x)    case x: return #x

◆ WINED3D_TO_STR [2/6]

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

◆ WINED3D_TO_STR [3/6]

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

◆ 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 176 of file utils.c.

Function Documentation

◆ add_ffp_frag_shader()

void add_ffp_frag_shader ( struct wine_rb_tree shaders,
struct ffp_frag_desc desc 
)

Definition at line 6021 of file utils.c.

6022 {
6023  /* Note that the key is the implementation independent part of the ffp_frag_desc structure,
6024  * whereas desc points to an extended structure with implementation specific parts. */
6025  if (wine_rb_put(shaders, &desc->settings, &desc->entry) == -1)
6026  {
6027  ERR("Failed to insert ffp frag shader.\n");
6028  }
6029 }
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define ERR(fmt,...)
Definition: debug.h:109
static int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct wine_rb_entry *entry)
Definition: rbtree.h:215
const GLuint * shaders
Definition: glext.h:7538

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 3144 of file utils.c.

3145 {
3146  unsigned int i;
3147  int idx;
3148 
3150  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3152 
3154  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3156 
3158  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3160 
3162  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3164 
3166  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3168 
3169  /* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by
3170  * any driver. */
3171  if (gl_info->supported[NV_TEXTURE_SHADER] || gl_info->supported[EXT_TEXTURE_SNORM])
3172  {
3173  /* R8G8_SNORM and R16G16_SNORM need a fixup of the undefined blue channel. OpenGL
3174  * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
3175  * conversion for this format. */
3177  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3180  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3182  }
3183  else
3184  {
3185  /* Emulate using unsigned formats. This requires load-time conversion in addition to the
3186  * fixups here. */
3188  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3191  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3194  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3197  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3199  }
3200 
3201  if (!gl_info->supported[NV_TEXTURE_SHADER])
3202  {
3204  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3206  }
3207 
3209  {
3211  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3213 
3215  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3217  }
3218  else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
3219  {
3221  gl_info->formats[idx].color_fixup= create_color_fixup_desc(
3223  }
3224 
3225  if (!gl_info->supported[APPLE_YCBCR_422] && (gl_info->supported[ARB_FRAGMENT_PROGRAM]
3226  || (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER])))
3227  {
3229  gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
3230 
3232  gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
3233  }
3234  else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
3235  && (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
3236  {
3238  gl_info->formats[idx].glInternal = 0;
3239 
3241  gl_info->formats[idx].glInternal = 0;
3242  }
3243 
3244  if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
3245  || (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
3246  {
3249  gl_info->formats[idx].height_scale.numerator = 3;
3250  gl_info->formats[idx].height_scale.denominator = 2;
3251  gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
3252 
3255  gl_info->formats[idx].height_scale.numerator = 3;
3256  gl_info->formats[idx].height_scale.denominator = 2;
3257  gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
3258  }
3259  else
3260  {
3262  gl_info->formats[idx].glInternal = 0;
3263 
3265  gl_info->formats[idx].glInternal = 0;
3266  }
3267 
3268  if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
3269  {
3271  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3274  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3277  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3280  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3283  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3285  }
3286 
3287  if (gl_info->supported[ARB_TEXTURE_RG])
3288  {
3290  gl_info->formats[idx].color_fixup = create_color_fixup_desc(
3292  }
3293 
3294  if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
3295  {
3297  gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
3298  }
3299 
3300  if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
3301  {
3303  gl_info->formats[idx].gl_vtx_format = GL_BGRA;
3304  }
3305 
3306  if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX])
3307  {
3308  /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
3309  * It is the job of the vertex buffer code to make sure that the vbos have the right format */
3311  gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
3312 
3314  gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
3315  }
3316 
3317  if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
3318  {
3321 
3324 
3327  }
3328 
3329  if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
3330  {
3333  }
3334 
3335  /* ATI instancing hack: Although ATI cards do not support Shader Model
3336  * 3.0, they support instancing. To query if the card supports instancing
3337  * CheckDeviceFormat() with the special format MAKEFOURCC('I','N','S','T')
3338  * is used. Should an application check for this, provide a proper return
3339  * value. We can do instancing with all shader versions, but we need
3340  * vertex shaders.
3341  *
3342  * Additionally applications have to set the D3DRS_POINTSIZE render state
3343  * to MAKEFOURCC('I','N','S','T') once to enable instancing. Wined3d
3344  * doesn't need that and just ignores it.
3345  *
3346  * With Shader Model 3.0 capable cards Instancing 'just works' in Windows. */
3347  /* FIXME: This should just check the shader backend caps. */
3348  if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
3349  {
3352  }
3353 
3354  /* Depth bound test. To query if the card supports it CheckDeviceFormat()
3355  * with the special format MAKEFOURCC('N','V','D','B') is used. It is
3356  * enabled by setting D3DRS_ADAPTIVETESS_X render state to
3357  * MAKEFOURCC('N','V','D','B') and then controlled by setting
3358  * D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax) to test
3359  * value. */
3360  if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
3361  {
3364  }
3365 
3366  /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
3367  * support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
3368  * RENDERTARGET usage. */
3369  if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
3370  {
3373  }
3374 
3375  for (i = 0; i < gl_info->format_count; ++i)
3376  {
3377  struct wined3d_format *format = &gl_info->formats[i];
3378 
3380  continue;
3381 
3382  if (is_identity_fixup(format->color_fixup))
3383  continue;
3384 
3385  TRACE("Checking support for fixup:\n");
3386  dump_color_fixup_desc(format->color_fixup);
3387  if (!adapter->shader_backend->shader_color_fixup_supported(format->color_fixup)
3388  || !adapter->fragment_pipe->color_fixup_supported(format->color_fixup))
3389  {
3390  TRACE("[FAILED]\n");
3392  }
3393  else
3394  {
3395  TRACE("[OK]\n");
3396  }
3397  }
3398 
3399  /* GL_EXT_texture_compression_s3tc does not support 3D textures. Some Windows drivers
3400  * for dx9 GPUs support it, some do not, so not supporting DXTn volumes is OK for d3d9.
3401  *
3402  * Note that GL_NV_texture_compression_vtc adds this functionality to OpenGL, but the
3403  * block layout is not compatible with the one used by d3d. See volume_dxt5_test. */
3426  /* Similarly with ATI1N / ATI2N and GL_ARB_texture_compression_rgtc. */
3439 }
static int get_format_idx(enum wined3d_format_id format_id)
Definition: utils.c:1696
static void format_set_flag(struct wined3d_format *format, unsigned int flag)
Definition: utils.c:1733
static struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
#define GL_FLOAT
Definition: gl.h:183
#define WINED3D_QUIRK_BROKEN_RGBA16
#define GL_BGRA
Definition: gl.h:1485
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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 WINED3DFMT_FLAG_TEXTURE
BOOL supported[WINED3D_GL_EXT_COUNT]
unsigned int idx
Definition: utils.c:41
struct wined3d_format * formats
#define TRACE(s)
Definition: solgame.cpp:4
const struct wined3d_shader_backend_ops * shader_backend
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
static void format_clear_flag(struct wined3d_format *format, unsigned int flag)
Definition: utils.c:1741
#define WINED3DFMT_FLAG_HEIGHT_SCALE
#define WINED3DFMT_FLAG_RENDERTARGET
const struct fragment_pipeline * fragment_pipe
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)
unsigned int format_count
void dump_color_fixup_desc(struct color_fixup_desc fixup)
Definition: utils.c:4792

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 3441 of file utils.c.

3442 {
3443  switch (type)
3444  {
3445  case GL_HALF_FLOAT:
3446  return component_count * sizeof(GLhalfNV);
3447  case GL_FLOAT:
3448  return component_count * sizeof(GLfloat);
3449  case GL_BYTE:
3450  return component_count * sizeof(GLbyte);
3451  case GL_UNSIGNED_BYTE:
3452  return component_count * sizeof(GLubyte);
3453  case GL_SHORT:
3454  return component_count * sizeof(GLshort);
3455  case GL_UNSIGNED_SHORT:
3456  return component_count * sizeof(GLushort);
3457  case GL_INT:
3458  return component_count * sizeof(GLint);
3459  case GL_UNSIGNED_INT:
3460  return component_count * sizeof(GLuint);
3462  return sizeof(GLuint);
3463  default:
3464  FIXME("Unhandled GL type %#x.\n", type);
3465  return 0;
3466  }
3467 }
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
unsigned char GLubyte
Definition: gl.h:157
#define GL_UNSIGNED_INT_2_10_10_10_REV
Definition: gl.h:1497
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_SHORT
Definition: gl.h:179
unsigned int component_count
#define FIXME(fmt,...)
Definition: debug.h:110
unsigned short GLhalfNV
Definition: glext.h:5520
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define GL_HALF_FLOAT
Definition: glext.h:1785
signed char GLbyte
Definition: gl.h:154
#define GL_BYTE
Definition: gl.h:177
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
unsigned short GLushort
Definition: gl.h:158

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 2173 of file utils.c.

2174 {
2175  /* Check if the default internal format is supported as a frame buffer
2176  * target, otherwise fall back to the render target internal.
2177  *
2178  * Try to stick to the standard format if possible, this limits precision differences. */
2179  static const struct wined3d_color black = {0.0f, 0.0f, 0.0f, 1.0f};
2180  static const struct wined3d_color half_transparent_red = {1.0f, 0.0f, 0.0f, 0.5f};
2181  const struct wined3d_gl_info *gl_info = ctx->gl_info;
2182  GLenum status, rt_internal = format->rtInternal;
2183  GLuint object, color_rb;
2185  BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
2186 
2187  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2188 
2189  for (type = 0; type < ARRAY_SIZE(format->flags); ++type)
2190  {
2191  const char *type_string = "color";
2192 
2194  continue;
2195 
2196  create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glInternal,
2197  format->glFormat, format->glType);
2198 
2200  {
2201  gl_info->fbo_ops.glGenRenderbuffers(1, &color_rb);
2202  gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, color_rb);
2204  gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 16, 1);
2205  else
2206  gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 16, 16);
2207 
2208  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER,
2210  checkGLcall("Create and attach color rb attachment");
2211  type_string = "depth / stencil";
2212  }
2213 
2214  status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2215  checkGLcall("Framebuffer format check");
2216 
2218  {
2219  TRACE("Format %s is supported as FBO %s attachment, type %u.\n",
2220  debug_d3dformat(format->id), type_string, type);
2222  format->rtInternal = format->glInternal;
2223  regular_fmt_used = TRUE;
2224  }
2225  else
2226  {
2227  if (!rt_internal)
2228  {
2230  {
2231  WARN("Format %s with rendertarget flag is not supported as FBO color attachment (type %u),"
2232  " and no fallback specified.\n", debug_d3dformat(format->id), type);
2234  }
2235  else
2236  {
2237  TRACE("Format %s is not supported as FBO %s attachment, type %u.\n",
2238  debug_d3dformat(format->id), type_string, type);
2239  }
2240  format->rtInternal = format->glInternal;
2241  }
2242  else
2243  {
2244  TRACE("Format %s is not supported as FBO %s attachment (type %u),"
2245  " trying rtInternal format as fallback.\n",
2246  debug_d3dformat(format->id), type_string, type);
2247 
2248  while (gl_info->gl_ops.gl.p_glGetError());
2249 
2250  delete_fbo_attachment(gl_info, type, object);
2251  create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->rtInternal,
2252  format->glFormat, format->glType);
2253 
2254  status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2255  checkGLcall("Framebuffer format check");
2256 
2258  {
2259  TRACE("Format %s rtInternal format is supported as FBO %s attachment, type %u.\n",
2260  debug_d3dformat(format->id), type_string, type);
2261  fallback_fmt_used = TRUE;
2262  }
2263  else
2264  {
2265  WARN("Format %s rtInternal format is not supported as FBO %s attachment, type %u.\n",
2266  debug_d3dformat(format->id), type_string, type);
2268  }
2269  }
2270  }
2271 
2275  && !(format->flags[type] & WINED3DFMT_FLAG_INTEGER)
2276  && format->id != WINED3DFMT_NULL && format->id != WINED3DFMT_P8_UINT
2277  && format->glFormat != GL_LUMINANCE && format->glFormat != GL_LUMINANCE_ALPHA
2278  && (format->red_size || format->alpha_size))
2279  {
2280  DWORD readback[16 * 16 * 16], color, r_range, a_range;
2281  BYTE r, a;
2282  BOOL match = TRUE;
2283  GLuint rb;
2284 
2285  if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
2286  || gl_info->supported[EXT_PACKED_DEPTH_STENCIL])
2287  {
2288  gl_info->fbo_ops.glGenRenderbuffers(1, &rb);
2289  gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, rb);
2291  gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 16, 1);
2292  else
2293  gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 16, 16);
2294  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
2295  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
2296  checkGLcall("RB attachment");
2297  }
2298 
2299  gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
2300  gl_info->gl_ops.gl.p_glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
2301  gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
2302  if (gl_info->gl_ops.gl.p_glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION)
2303  {
2304  while (gl_info->gl_ops.gl.p_glGetError());
2305  TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
2306  debug_d3dformat(format->id), type);
2308  }
2309  else
2310  {
2311  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2313  gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 1);
2314  else
2315  gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 16);
2316  gl_info->gl_ops.gl.p_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2317 
2318  draw_test_quad(ctx, NULL, &black);
2319 
2320  gl_info->gl_ops.gl.p_glEnable(GL_BLEND);
2321 
2322  draw_test_quad(ctx, NULL, &half_transparent_red);
2323 
2324  gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
2325 
2326  switch (type)
2327  {
2329  /* Rebinding texture to workaround a fglrx bug. */
2330  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, object);
2331  gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_1D, 0, GL_BGRA,
2332  GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2333  color = readback[7];
2334  break;
2335 
2339  /* Rebinding texture to workaround a fglrx bug. */
2340  gl_info->gl_ops.gl.p_glBindTexture(wined3d_gl_type_to_enum(type), object);
2341  gl_info->gl_ops.gl.p_glGetTexImage(wined3d_gl_type_to_enum(type), 0, GL_BGRA,
2342  GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2343  color = readback[7 * 16 + 7];
2344  break;
2345 
2347  /* Rebinding texture to workaround a fglrx bug. */
2348  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, object);
2349  gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_BGRA,
2350  GL_UNSIGNED_INT_8_8_8_8_REV, readback);
2351  color = readback[7 * 16 + 7];
2352  break;
2353 
2355  gl_info->gl_ops.gl.p_glReadPixels(0, 0, 16, 16,
2357  color = readback[7 * 16 + 7];
2358  break;
2359 
2362  color = 0;
2363  break;
2364  }
2365  checkGLcall("Post-pixelshader blending check");
2366 
2367  a = color >> 24;
2368  r = (color & 0x00ff0000u) >> 16;
2369 
2370  r_range = format->red_size < 8 ? 1u << (8 - format->red_size) : 1;
2371  a_range = format->alpha_size < 8 ? 1u << (8 - format->alpha_size) : 1;
2372  if (format->red_size && (r < 0x7f - r_range || r > 0x7f + r_range))
2373  match = FALSE;
2374  else if (format->alpha_size > 1 && (a < 0xbf - a_range || a > 0xbf + a_range))
2375  match = FALSE;
2376  if (!match)
2377  {
2378  TRACE("Format %s doesn't support post-pixelshader blending, type %u.\n",
2379  debug_d3dformat(format->id), type);
2380  TRACE("Color output: %#x\n", color);
2382  }
2383  else
2384  {
2385  TRACE("Format %s supports post-pixelshader blending, type %u.\n",
2386  debug_d3dformat(format->id), type);
2387  TRACE("Color output: %#x\n", color);
2389  }
2390  }
2391 
2392  if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
2393  || gl_info->supported[EXT_PACKED_DEPTH_STENCIL])
2394  {
2395  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
2396  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
2397  gl_info->fbo_ops.glDeleteRenderbuffers(1, &rb);
2398  checkGLcall("RB cleanup");
2399  }
2400  }
2401 
2402  if (format->glInternal != format->glGammaInternal)
2403  {
2404  delete_fbo_attachment(gl_info, type, object);
2405  create_and_bind_fbo_attachment(gl_info, format->flags[type], type, &object, format->glGammaInternal,
2406  format->glFormat, format->glType);
2407 
2408  status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2409  checkGLcall("Framebuffer format check");
2410 
2412  {
2413  TRACE("Format %s's sRGB format is FBO attachable, type %u.\n",
2414  debug_d3dformat(format->id), type);
2416  if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
2417  format->glInternal = format->glGammaInternal;
2418  }
2419  else
2420  {
2421  WARN("Format %s's sRGB format is not FBO attachable, type %u.\n",
2422  debug_d3dformat(format->id), type);
2424  }
2425  }
2426  else if (status == GL_FRAMEBUFFER_COMPLETE)
2428 
2430  {
2431  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
2432  gl_info->fbo_ops.glDeleteRenderbuffers(1, &color_rb);
2433  }
2434 
2435  delete_fbo_attachment(gl_info, type, object);
2436  checkGLcall("Framebuffer format check cleanup");
2437  }
2438 
2439  if (fallback_fmt_used && regular_fmt_used)
2440  {
2441  FIXME("Format %s needs different render target formats for different resource types.\n",
2442  debug_d3dformat(format->id));
2445  }
2446 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define WINED3DFMT_FLAG_STENCIL
#define GL_RENDERBUFFER
Definition: glext.h:1733
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
#define TRUE
Definition: types.h:120
struct opengl_funcs gl_ops
static void delete_fbo_attachment(const struct wined3d_gl_info *gl_info, enum wined3d_gl_resource_type d3d_type, GLuint object)
Definition: utils.c:1925
#define GL_BLEND
Definition: gl.h:371
#define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
Definition: match.c:28
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define GL_DEPTH24_STENCIL8
Definition: glext.h:1687
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define GL_BGRA
Definition: gl.h:1485
wined3d_gl_resource_type
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define WINED3DFMT_FLAG_INTEGER
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_TEXTURE_1D
Definition: gl.h:644
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
#define a
Definition: ke_i.h:78
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL supported[WINED3D_GL_EXT_COUNT]
#define WINED3D_QUIRK_LIMITED_TEX_FILTERING
smooth NULL
Definition: ftsmooth.c:416
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_FRAMEBUFFER_COMPLETE
Definition: glext.h:1707
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3DFMT_FLAG_SRGB_WRITE
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition: gl.h:1495
unsigned long DWORD
Definition: ntddk_ex.h:95
static void format_clear_flag(struct wined3d_format *format, unsigned int flag)
Definition: utils.c:1741
#define GL_RGBA8
Definition: gl.h:762
#define WINED3DFMT_FLAG_FBO_ATTACHABLE
unsigned char BYTE
Definition: mem.h:68
unsigned int GLenum
Definition: gl.h:150
#define WINED3DFMT_FLAG_RENDERTARGET
#define GL_LUMINANCE
Definition: gl.h:484
static void draw_test_quad(struct wined3d_caps_gl_ctx *ctx, const struct wined3d_vec3 *geometry, const struct wined3d_color *color)
Definition: utils.c:2050
unsigned int GLuint
Definition: gl.h:159
#define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
#define ARRAY_SIZE(a)
Definition: main.h:24
#define checkGLcall(A)
#define GL_INVALID_FRAMEBUFFER_OPERATION
Definition: glext.h:1672
#define GL_ONE_MINUS_SRC_ALPHA
Definition: gl.h:379
static GLenum wined3d_gl_type_to_enum(enum wined3d_gl_resource_type type)
Definition: utils.c:1900
struct wined3d_fbo_ops fbo_ops
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
Definition: glext.h:1232
#define GL_SRC_ALPHA
Definition: gl.h:378
#define WINED3DFMT_FLAG_DEPTH
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
static SERVICE_STATUS status
Definition: service.c:31
const struct wined3d_gl_info * gl_info
void * object
Definition: jmemsys.h:48
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:1949
Definition: ps.c:97

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 2979 of file utils.c.

2980 {
2981  static const DWORD data[] = {0x00000000, 0xffffffff};
2982  GLuint tex, fbo, buffer;
2983  DWORD readback[16 * 1];
2984  BOOL ret = FALSE;
2985 
2986  /* Render a filtered texture and see what happens. This is intended to detect the lack of
2987  * float16 filtering on ATI X1000 class cards. The drivers disable filtering instead of
2988  * falling back to software. If this changes in the future this code will get fooled and
2989  * apps might hit the software path due to incorrectly advertised caps.
2990  *
2991  * Its unlikely that this changes however. GL Games like Mass Effect depend on the filter
2992  * disable fallback, if Apple or ATI ever change the driver behavior they will break more
2993  * than Wine. The Linux binary <= r500 driver is not maintained any more anyway
2994  */
2995 
2996  while (gl_info->gl_ops.gl.p_glGetError());
2997 
2998  gl_info->gl_ops.gl.p_glGenTextures(1, &buffer);
2999  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, buffer);
3000  memset(readback, 0x7e, sizeof(readback));
3001  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 1, 0,
3002  GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, readback);
3003  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3004  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3005  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3006  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3007  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
3008 
3009  gl_info->gl_ops.gl.p_glGenTextures(1, &tex);
3010  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, tex);
3011  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_2D, 0, internal, 2, 1, 0,
3013  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
3014  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3015  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3016  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3017  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
3018  gl_info->gl_ops.gl.p_glEnable(GL_TEXTURE_2D);
3019 
3020  gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
3021  gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3022  gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, buffer, 0);
3023  gl_info->gl_ops.gl.p_glDrawBuffer(GL_COLOR_ATTACHMENT0);
3024 
3025  gl_info->gl_ops.gl.p_glViewport(0, 0, 16, 1);
3026  gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING);
3027  gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
3028  gl_info->gl_ops.gl.p_glLoadIdentity();
3029  gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
3030  gl_info->gl_ops.gl.p_glLoadIdentity();
3031 
3032  gl_info->gl_ops.gl.p_glClearColor(0, 1, 0, 0);
3033  gl_info->gl_ops.gl.p_glClear(GL_COLOR_BUFFER_BIT);
3034 
3035  gl_info->gl_ops.gl.p_glBegin(GL_TRIANGLE_STRIP);
3036  gl_info->gl_ops.gl.p_glTexCoord2f(0.0, 0.0);
3037  gl_info->gl_ops.gl.p_glVertex2f(-1.0f, -1.0f);
3038  gl_info->gl_ops.gl.p_glTexCoord2f(1.0, 0.0);
3039  gl_info->gl_ops.gl.p_glVertex2f(1.0f, -1.0f);
3040  gl_info->gl_ops.gl.p_glTexCoord2f(0.0, 1.0);
3041  gl_info->gl_ops.gl.p_glVertex2f(-1.0f, 1.0f);
3042  gl_info->gl_ops.gl.p_glTexCoord2f(1.0, 1.0);
3043  gl_info->gl_ops.gl.p_glVertex2f(1.0f, 1.0f);
3044  gl_info->gl_ops.gl.p_glEnd();
3045 
3046  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, buffer);
3047  memset(readback, 0x7f, sizeof(readback));
3048  gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, readback);
3049  if (color_match(readback[6], 0xffffffff, 5) || color_match(readback[6], 0x00000000, 5)
3050  || color_match(readback[9], 0xffffffff, 5) || color_match(readback[9], 0x00000000, 5))
3051  {
3052  TRACE("Read back colors 0x%08x and 0x%08x close to unfiltered color, assuming no filtering\n",
3053  readback[6], readback[9]);
3054  ret = FALSE;
3055  }
3056  else
3057  {
3058  TRACE("Read back colors are 0x%08x and 0x%08x, assuming texture is filtered\n",
3059  readback[6], readback[9]);
3060  ret = TRUE;
3061  }
3062 
3063  gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3064  gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
3065  gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex);
3066  gl_info->gl_ops.gl.p_glDeleteTextures(1, &buffer);
3067  gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D);
3068 
3069  if (gl_info->gl_ops.gl.p_glGetError())
3070  {
3071  FIXME("Error during filtering test for format %x, returning no filtering\n", internal);
3072  ret = FALSE;
3073  }
3074 
3075  return ret;
3076 }
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:716
#define TRUE
Definition: types.h:120
struct opengl_funcs gl_ops
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
#define GL_NEAREST
Definition: gl.h:678
GLuint buffer
Definition: glext.h:5915
#define GL_BGRA
Definition: gl.h:1485
#define GL_TEXTURE_WRAP_R
Definition: gl.h:1518
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_UNSIGNED_INT_8_8_8_8
Definition: gl.h:1494
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition: gl.h:1495
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_LIGHTING
Definition: gl.h:310
#define GL_LINEAR
Definition: gl.h:421
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_RGBA8
Definition: gl.h:762
int ret
#define GL_PROJECTION
Definition: gl.h:246
static BOOL color_match(DWORD c1, DWORD c2, BYTE max_diff)
Definition: utils.c:2966
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_MODELVIEW
Definition: gl.h:245
#define GL_TEXTURE_2D
Definition: gl.h:645
struct wined3d_fbo_ops fbo_ops
#define GL_RGBA
Definition: gl.h:503
#define GL_TRIANGLE_STRIP
Definition: gl.h:195
#define memset(x, y, z)
Definition: compat.h:39

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 887 of file utils.c.

888 {
889  /* FIXME: Is this really how color keys are supposed to work? I think it
890  * makes more sense to compare the individual channels. */
891  return color >= color_key->color_space_low_value
892  && color <= color_key->color_space_high_value;
893 }
GLuint color
Definition: glext.h:6243

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 2966 of file utils.c.

2967 {
2968  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
2969  c1 >>= 8; c2 >>= 8;
2970  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
2971  c1 >>= 8; c2 >>= 8;
2972  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
2973  c1 >>= 8; c2 >>= 8;
2974  if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
2975  return TRUE;
2976 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120

Referenced by check_filter().

◆ color_to_float()

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

Definition at line 5250 of file utils.c.

5251 {
5252  DWORD mask = size < 32 ? (1u << size) - 1 : ~0u;
5253 
5254  if (!size)
5255  return 1.0f;
5256 
5257  color >>= offset;
5258  color &= mask;
5259 
5260  return (float)color / (float)mask;
5261 }
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
GLintptr offset
Definition: glext.h:5920
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint color
Definition: glext.h:6243
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95

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 4925 of file utils.c.

4928 {
4929  struct wined3d_matrix mat;
4930 
4931  if (flags == WINED3D_TTFF_DISABLE || flags == WINED3D_TTFF_COUNT1 || transformed)
4932  {
4933  get_identity_matrix(out_matrix);
4934  return;
4935  }
4936 
4938  {
4939  ERR("Invalid texture transform flags: WINED3D_TTFF_COUNT1 | WINED3D_TTFF_PROJECTED.\n");
4940  return;
4941  }
4942 
4943  mat = *matrix;
4944 
4946  {
4947  if (!ffp_proj_control)
4948  {
4949  switch (flags & ~WINED3D_TTFF_PROJECTED)
4950  {
4951  case WINED3D_TTFF_COUNT2:
4952  mat._14 = mat._12;
4953  mat._24 = mat._22;
4954  mat._34 = mat._32;
4955  mat._44 = mat._42;
4956  mat._12 = mat._22 = mat._32 = mat._42 = 0.0f;
4957  break;
4958  case WINED3D_TTFF_COUNT3:
4959  mat._14 = mat._13;
4960  mat._24 = mat._23;
4961  mat._34 = mat._33;
4962  mat._44 = mat._43;
4963  mat._13 = mat._23 = mat._33 = mat._43 = 0.0f;
4964  break;
4965  }
4966  }
4967  }
4968  else
4969  {
4970  /* Under Direct3D the R/Z coord can be used for translation, under
4971  * OpenGL we use the Q coord instead. */
4972  if (!calculated_coords)
4973  {
4974  switch (format_id)
4975  {
4976  /* Direct3D passes the default 1.0 in the 2nd coord, while GL
4977  * passes it in the 4th. Swap 2nd and 4th coord. No need to
4978  * store the value of mat._41 in mat._21 because the input
4979  * value to the transformation will be 0, so the matrix value
4980  * is irrelevant. */
4981  case WINED3DFMT_R32_FLOAT:
4982  mat._41 = mat._21;
4983  mat._42 = mat._22;
4984  mat._43 = mat._23;
4985  mat._44 = mat._24;
4986  break;
4987  /* See above, just 3rd and 4th coord. */
4989  mat._41 = mat._31;
4990  mat._42 = mat._32;
4991  mat._43 = mat._33;
4992  mat._44 = mat._34;
4993  break;
4994  case WINED3DFMT_R32G32B32_FLOAT: /* Opengl defaults match dx defaults */
4995  case WINED3DFMT_R32G32B32A32_FLOAT: /* No defaults apply, all app defined */
4996 
4997  /* This is to prevent swapping the matrix lines and put the default 4th coord = 1.0
4998  * into a bad place. The division elimination below will apply to make sure the
4999  * 1.0 doesn't do anything bad. The caller will set this value if the stride is 0
5000  */
5001  case WINED3DFMT_UNKNOWN: /* No texture coords, 0/0/0/1 defaults are passed */
5002  break;
5003  default:
5004  FIXME("Unexpected fixed function texture coord input\n");
5005  }
5006  }
5007  if (!ffp_proj_control)
5008  {
5009  switch (flags & ~WINED3D_TTFF_PROJECTED)
5010  {
5011  /* case WINED3D_TTFF_COUNT1: Won't ever get here. */
5012  case WINED3D_TTFF_COUNT2:
5013  mat._13 = mat._23 = mat._33 = mat._43 = 0.0f;
5014  /* OpenGL divides the first 3 vertex coordinates by the 4th by
5015  * default, which is essentially the same as D3DTTFF_PROJECTED.
5016  * Make sure that the 4th coordinate evaluates to 1.0 to
5017  * eliminate that.
5018  *
5019  * If the fixed function pipeline is used, the 4th value
5020  * remains unused, so there is no danger in doing this. With
5021  * vertex shaders we have a problem. Should an application hit
5022  * that problem, the code here would have to check for pixel
5023  * shaders, and the shader has to undo the default GL divide.
5024  *
5025  * A more serious problem occurs if the application passes 4
5026  * coordinates in, and the 4th is != 1.0 (OpenGL default).
5027  * This would have to be fixed with immediate mode draws. */
5028  default:
5029  mat._14 = mat._24 = mat._34 = 0.0f; mat._44 = 1.0f;
5030  }
5031  }
5032  }
5033 
5034  *out_matrix = mat;
5035 }
void get_identity_matrix(struct wined3d_matrix *mat)
Definition: utils.c:4827
GLuint GLenum matrix
Definition: glext.h:9407
static const MAT2 mat
Definition: font.c:66
#define FIXME(fmt,...)
Definition: debug.h:110
GLbitfield flags
Definition: glext.h:7161
#define ERR(fmt,...)
Definition: debug.h:109
static UINT format_id
Definition: clipboard.c:1343

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

Definition at line 918 of file utils.c.

921 {
922  const WORD *src_row;
923  unsigned int x, y;
924  WORD *dst_row;
925 
926  for (y = 0; y < height; ++y)
927  {
928  src_row = (WORD *)&src[src_pitch * y];
929  dst_row = (WORD *)&dst[dst_pitch * y];
930  for (x = 0; x < width; ++x)
931  {
932  WORD src_color = src_row[x];
933  if (color_in_range(color_key, src_color))
934  dst_row[x] = src_color & ~0x8000;
935  else
936  dst_row[x] = src_color | 0x8000;
937  }
938  }
939 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned short WORD
Definition: ntddk_ex.h:93
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:887

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

Definition at line 895 of file utils.c.

898 {
899  const WORD *src_row;
900  unsigned int x, y;
901  WORD *dst_row;
902 
903  for (y = 0; y < height; ++y)
904  {
905  src_row = (WORD *)&src[src_pitch * y];
906  dst_row = (WORD *)&dst[dst_pitch * y];
907  for (x = 0; x < width; ++x)
908  {
909  WORD src_color = src_row[x];
910  if (!color_in_range(color_key, src_color))
911  dst_row[x] = 0x8000u | ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu);
912  else
913  dst_row[x] = ((src_color & 0xffc0u) >> 1) | (src_color & 0x1fu);
914  }
915  }
916 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned short WORD
Definition: ntddk_ex.h:93
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:887

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

Definition at line 941 of file utils.c.

944 {
945  const BYTE *src_row;
946  unsigned int x, y;
947  DWORD *dst_row;
948 
949  for (y = 0; y < height; ++y)
950  {
951  src_row = &src[src_pitch * y];
952  dst_row = (DWORD *)&dst[dst_pitch * y];
953  for (x = 0; x < width; ++x)
954  {
955  DWORD src_color = (src_row[x * 3 + 2] << 16) | (src_row[x * 3 + 1] << 8) | src_row[x * 3];
956  if (!color_in_range(color_key, src_color))
957  dst_row[x] = src_color | 0xff000000;
958  }
959  }
960 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:887

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

Definition at line 985 of file utils.c.

988 {
989  const DWORD *src_row;
990  unsigned int x, y;
991  DWORD *dst_row;
992 
993  for (y = 0; y < height; ++y)
994  {
995  src_row = (DWORD *)&src[src_pitch * y];
996  dst_row = (DWORD *)&dst[dst_pitch * y];
997  for (x = 0; x < width; ++x)
998  {
999  DWORD src_color = src_row[x];
1000  if (color_in_range(color_key, src_color))
1001  src_color &= ~0xff000000;
1002  dst_row[x] = src_color;
1003  }
1004  }
1005 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:887

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

Definition at line 962 of file utils.c.

965 {
966  const DWORD *src_row;
967  unsigned int x, y;
968  DWORD *dst_row;
969 
970  for (y = 0; y < height; ++y)
971  {
972  src_row = (DWORD *)&src[src_pitch * y];
973  dst_row = (DWORD *)&dst[dst_pitch * y];
974  for (x = 0; x < width; ++x)
975  {
976  DWORD src_color = src_row[x];
977  if (color_in_range(color_key, src_color))
978  dst_row[x] = src_color & ~0xff000000;
979  else
980  dst_row[x] = src_color | 0xff000000;
981  }
982  }
983 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static BOOL color_in_range(const struct wined3d_color_key *color_key, DWORD color)
Definition: utils.c:887

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 442 of file utils.c.

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

◆ 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 721 of file utils.c.

723 {
724  unsigned int x, y, z;
725  const WORD *Source;
726  WORD *Dest;
727 
728  for (z = 0; z < depth; z++)
729  {
730  for (y = 0; y < height; y++)
731  {
732  Source = (const WORD *)(src + z * src_slice_pitch + y * src_row_pitch);
733  Dest = (WORD *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
734  for (x = 0; x < width; x++ )
735  {
736  WORD green = (*Source++);
737  WORD red = (*Source++);
738  Dest[0] = green;
739  Dest[1] = red;
740  /* Strictly speaking not correct for R16G16F, but it doesn't matter because the
741  * shader overwrites it anyway */
742  Dest[2] = 0xffff;
743  Dest += 3;
744  }
745  }
746  }
747 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
unsigned short WORD
Definition: ntddk_ex.h:93
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 696 of file utils.c.

698 {
699  unsigned int x, y, z;
700  const DWORD *Source;
701  unsigned short *Dest;
702 
703  for (z = 0; z < depth; z++)
704  {
705  for (y = 0; y < height; y++)
706  {
707  Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
708  Dest = (unsigned short *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
709  for (x = 0; x < width; x++ )
710  {
711  const DWORD color = (*Source++);
712  /* B */ Dest[0] = 0xffff;
713  /* G */ Dest[1] = (color >> 16) + 32768; /* V */
714  /* R */ Dest[2] = (color & 0xffff) + 32768; /* U */
715  Dest += 3;
716  }
717  }
718  }
719 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 749 of file utils.c.

751 {
752  unsigned int x, y, z;
753  const float *Source;
754  float *Dest;
755 
756  for (z = 0; z < depth; z++)
757  {
758  for (y = 0; y < height; y++)
759  {
760  Source = (const float *)(src + z * src_slice_pitch + y * src_row_pitch);
761  Dest = (float *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
762  for (x = 0; x < width; x++ )
763  {
764  float green = (*Source++);
765  float red = (*Source++);
766  Dest[0] = green;
767  Dest[1] = red;
768  Dest[2] = 1.0f;
769  Dest += 3;
770  }
771  }
772  }
773 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 470 of file utils.c.

472 {
473  unsigned int x, y, z;
474  unsigned char r_in, g_in, l_in;
475  const unsigned short *texel_in;
476  unsigned short *texel_out;
477 
478  /* Emulating signed 5 bit values with unsigned 5 bit values has some precision problems by design:
479  * E.g. the signed input value 0 becomes 16. GL normalizes it to 16 / 31 = 0.516. We convert it
480  * back to a signed value by subtracting 0.5 and multiplying by 2.0. The resulting value is
481  * ((16 / 31) - 0.5) * 2.0 = 0.032, which is quite different from the intended result 0.000. */
482  for (z = 0; z < depth; z++)
483  {
484  for (y = 0; y < height; y++)
485  {
486  texel_out = (unsigned short *) (dst + z * dst_slice_pitch + y * dst_row_pitch);
487  texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
488  for (x = 0; x < width; x++ )
489  {
490  l_in = (*texel_in & 0xfc00u) >> 10;
491  g_in = (*texel_in & 0x03e0u) >> 5;
492  r_in = *texel_in & 0x001fu;
493 
494  *texel_out = ((r_in + 16) << 11) | (l_in << 5) | (g_in + 16);
495  texel_out++;
496  texel_in++;
497  }
498  }
499  }
500 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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 502 of file utils.c.

504 {
505  unsigned int x, y, z;
506  unsigned char *texel_out, r_out, g_out, r_in, g_in, l_in;
507  const unsigned short *texel_in;
508 
509  for (z = 0; z < depth; z++)
510  {
511  for (y = 0; y < height; y++)
512  {
513  texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
514  texel_out = dst + z * dst_slice_pitch + y * dst_row_pitch;
515  for (x = 0; x < width; x++ )
516  {
517  l_in = (*texel_in & 0xfc00u) >> 10;
518  g_in = (*texel_in & 0x03e0u) >> 5;
519  r_in = *texel_in & 0x001fu;
520 
521  r_out = r_in << 3;
522  if (!(r_in & 0x10)) /* r > 0 */
523  r_out |= r_in >> 1;
524 
525  g_out = g_in << 3;
526  if (!(g_in & 0x10)) /* g > 0 */
527  g_out |= g_in >> 1;
528 
529  texel_out[0] = r_out;
530  texel_out[1] = g_out;
531  texel_out[2] = l_in << 1 | l_in >> 5;
532  texel_out[3] = 0;
533 
534  texel_out += 4;
535  texel_in++;
536  }
537  }
538  }
539 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static struct stream g_out[STREAM_COUNT]
Definition: tcp.c:74
GLdouble GLdouble z
Definition: glext.h:5874
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static struct stream g_in
Definition: tcp.c:73

◆ 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 541 of file utils.c.

543 {
544  unsigned int x, y, z;
545  unsigned char *texel_out, ds_out, dt_out, r_in, g_in, l_in;
546  const unsigned short *texel_in;
547 
548  /* This makes the gl surface bigger(24 bit instead of 16), but it works with
549  * fixed function and shaders without further conversion once the surface is
550  * loaded.
551  *
552  * The difference between this function and convert_r5g5_snorm_l6_unorm_ext
553  * is that convert_r5g5_snorm_l6_unorm_ext creates a 32 bit XRGB texture and
554  * this function creates a 24 bit DSDT_MAG texture. Trying to load a DSDT_MAG
555  * internal with a 32 bit DSDT_MAG_INTENSITY or DSDT_MAG_VIB format fails. */
556  for (z = 0; z < depth; z++)
557  {
558  for (y = 0; y < height; y++)
559  {
560  texel_in = (const unsigned short *)(src + z * src_slice_pitch + y * src_row_pitch);
561  texel_out = dst + z * dst_slice_pitch + y * dst_row_pitch;
562  for (x = 0; x < width; x++ )
563  {
564  l_in = (*texel_in & 0xfc00u) >> 10;
565  g_in = (*texel_in & 0x03e0u) >> 5;
566  r_in = *texel_in & 0x001fu;
567 
568  ds_out = r_in << 3;
569  if (!(r_in & 0x10)) /* r > 0 */
570  ds_out |= r_in >> 1;
571 
572  dt_out = g_in << 3;
573  if (!(g_in & 0x10)) /* g > 0 */
574  dt_out |= g_in >> 1;
575 
576  texel_out[0] = ds_out;
577  texel_out[1] = dt_out;
578  texel_out[2] = l_in << 1 | l_in >> 5;
579 
580  texel_out += 3;
581  texel_in++;
582  }
583  }
584  }
585 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static struct stream g_in
Definition: tcp.c:73

◆ 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 587 of file utils.c.

589 {
590  unsigned int x, y, z;
591  const short *Source;
592  unsigned char *Dest;
593 
594  for (z = 0; z < depth; z++)
595  {
596  for (y = 0; y < height; y++)
597  {
598  Source = (const short *)(src + z * src_slice_pitch + y * src_row_pitch);
599  Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
600  for (x = 0; x < width; x++ )
601  {
602  const short color = (*Source++);
603  /* B */ Dest[0] = 0xff;
604  /* G */ Dest[1] = (color >> 8) + 128; /* V */
605  /* R */ Dest[2] = (color & 0xff) + 128; /* U */
606  Dest += 3;
607  }
608  }
609  }
610 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 612 of file utils.c.

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

◆ 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 641 of file utils.c.

643 {
644  unsigned int x, y, z;
645  const DWORD *Source;
646  unsigned char *Dest;
647 
648  /* This implementation works with the fixed function pipeline and shaders
649  * without further modification after converting the surface.
650  */
651  for (z = 0; z < depth; z++)
652  {
653  for (y = 0; y < height; y++)
654  {
655  Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
656  Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
657  for (x = 0; x < width; x++ )
658  {
659  LONG color = (*Source++);
660  /* L */ Dest[2] = ((color >> 16) & 0xff); /* L */
661  /* V */ Dest[1] = ((color >> 8 ) & 0xff); /* V */
662  /* U */ Dest[0] = (color & 0xff); /* U */
663  /* I */ Dest[3] = 255; /* X */
664  Dest += 4;
665  }
666  }
667  }
668 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
long LONG
Definition: pedump.c:60
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 670 of file utils.c.

672 {
673  unsigned int x, y, z;
674  const DWORD *Source;
675  unsigned char *Dest;
676 
677  for (z = 0; z < depth; z++)
678  {
679  for (y = 0; y < height; y++)
680  {
681  Source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
682  Dest = dst + z * dst_slice_pitch + y * dst_row_pitch;
683  for (x = 0; x < width; x++ )
684  {
685  LONG color = (*Source++);
686  /* B */ Dest[0] = ((color >> 16) & 0xff) + 128; /* W */
687  /* G */ Dest[1] = ((color >> 8 ) & 0xff) + 128; /* V */
688  /* R */ Dest[2] = (color & 0xff) + 128; /* U */
689  /* A */ Dest[3] = ((color >> 24) & 0xff) + 128; /* Q */
690  Dest += 4;
691  }
692  }
693  }
694 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
long LONG
Definition: pedump.c:60
GLuint color
Definition: glext.h:6243
GLdouble GLdouble z
Definition: glext.h:5874
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3149

◆ 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 775 of file utils.c.

777 {
778  unsigned int x, y, z;
779 
780  for (z = 0; z < depth; z++)
781  {
782  for (y = 0; y < height; ++y)
783  {
784  const WORD *source = (const WORD *)(src + z * src_slice_pitch + y * src_row_pitch);
785  DWORD *dest = (DWORD *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
786 
787  for (x = 0; x < width; ++x)
788  {
789  /* The depth data is normalized, so needs to be scaled,
790  * the stencil data isn't. Scale depth data by
791  * (2^24-1)/(2^15-1) ~~ (2^9 + 2^-6). */
792  WORD d15 = source[x] >> 1;
793  DWORD d24 = (d15 << 9) + (d15 >> 6);
794  dest[x] = (d24 << 8) | (source[x] & 0x1);
795  }
796  }
797  }
798 }
GLint GLint GLsizei width
Definition: gl.h:1546
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
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 800 of file utils.c.

802 {
803  unsigned int x, y, z;
804 
805  for (z = 0; z < depth; z++)
806  {
807  for (y = 0; y < height; ++y)
808  {
809  const DWORD *source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
810  DWORD *dest = (DWORD *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
811 
812  for (x = 0; x < width; ++x)
813  {
814  /* Just need to clear out the X4 part. */
815  dest[x] = source[x] & ~0xf0;
816  }
817  }
818  }
819 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static char * dest
Definition: rtl.c:135

◆ 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 821 of file utils.c.

823 {
824  unsigned int x, y, z;
825 
826  for (z = 0; z < depth; z++)
827  {
828  for (y = 0; y < height; ++y)
829  {
830  const DWORD *source = (const DWORD *)(src + z * src_slice_pitch + y * src_row_pitch);
831  float *dest_f = (float *)(dst + z * dst_slice_pitch + y * dst_row_pitch);
832  DWORD *dest_s = (DWORD *)dest_f;
833 
834  for (x = 0; x < width; ++x)
835  {
836  dest_f[x * 2] = float_24_to_32((source[x] & 0xffffff00u) >> 8);
837  dest_s[x * 2 + 1] = source[x] & 0xff;
838  }
839  }
840  }
841 }
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static float float_24_to_32(DWORD in)
GLdouble GLdouble z
Definition: glext.h:5874
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLenum GLenum dst
Definition: glext.h:6340
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ copy_format()

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

Definition at line 1726 of file utils.c.

1727 {
1728  enum wined3d_format_id id = dst_format->id;
1729  *dst_format = *src_format;
1730  dst_format->id = id;
1731 }
static const char * dst_format
Definition: dib.c:1133
enum wined3d_format_id id
Definition: utils.c:40
wined3d_format_id
Definition: wined3d.h:105

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 1949 of file utils.c.

1951 {
1952  GLenum attach_type = flags & WINED3DFMT_FLAG_DEPTH ?
1954 
1955  switch (d3d_type)
1956  {
1958  gl_info->gl_ops.gl.p_glGenTextures(1, object);
1959  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, *object);
1960  gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, internal, 16, 0, format, type, NULL);
1961  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1962  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1963 
1964  gl_info->fbo_ops.glFramebufferTexture1D(GL_FRAMEBUFFER, attach_type, GL_TEXTURE_1D,
1965  *object, 0);
1967  gl_info->fbo_ops.glFramebufferTexture1D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_1D,
1968  *object, 0);
1969  break;
1970 
1973  gl_info->gl_ops.gl.p_glGenTextures(1, object);
1974  gl_info->gl_ops.gl.p_glBindTexture(wined3d_gl_type_to_enum(d3d_type), *object);
1975  gl_info->gl_ops.gl.p_glTexImage2D(wined3d_gl_type_to_enum(d3d_type), 0, internal, 16, 16, 0,
1976  format, type, NULL);
1977  gl_info->gl_ops.gl.p_glTexParameteri(wined3d_gl_type_to_enum(d3d_type), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1978  gl_info->gl_ops.gl.p_glTexParameteri(wined3d_gl_type_to_enum(d3d_type), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1979 
1980  gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, attach_type,
1981  wined3d_gl_type_to_enum(d3d_type), *object, 0);
1983  gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
1984  wined3d_gl_type_to_enum(d3d_type), *object, 0);
1985  break;
1986 
1988  gl_info->gl_ops.gl.p_glGenTextures(1, object);
1989  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_3D, *object);
1990  GL_EXTCALL(glTexImage3D(GL_TEXTURE_3D, 0, internal, 16, 16, 16, 0, format, type, NULL));
1991  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1992  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1993 
1994  gl_info->fbo_ops.glFramebufferTexture3D(GL_FRAMEBUFFER, attach_type,
1995  GL_TEXTURE_3D, *object, 0, 0);
1997  gl_info->fbo_ops.glFramebufferTexture3D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
1998  GL_TEXTURE_3D, *object, 0, 0);
1999  break;
2000 
2002  gl_info->gl_ops.gl.p_glGenTextures(1, object);
2003  gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, *object);
2004  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, internal, 16, 16, 0,
2005  format, type, NULL);
2006  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 0, internal, 16, 16, 0,
2007  format, type, NULL);
2008  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, 0, internal, 16, 16, 0,
2009  format, type, NULL);
2010  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, 0, internal, 16, 16, 0,
2011  format, type, NULL);
2012  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, 0, internal, 16, 16, 0,
2013  format, type, NULL);
2014  gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, 0, internal, 16, 16, 0,
2015  format, type, NULL);
2016  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2017  gl_info->gl_ops.gl.p_glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2018 
2019  gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, attach_type,
2022  gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2024  break;
2025 
2027  gl_info->fbo_ops.glGenRenderbuffers(1, object);
2028  gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, *object);
2029  gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, internal, 16, 16);
2030  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, attach_type, GL_RENDERBUFFER,
2031  *object);
2033  gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
2034  *object);
2035  break;
2036 
2039  break;
2040  }
2041 
2042  /* Ideally we'd skip all formats already known not to work on textures
2043  * by checking for WINED3DFMT_FLAG_TEXTURE here. However, we want to
2044  * know if we can attach WINED3DFMT_P8_UINT textures to FBOs, and this
2045  * format never has WINED3DFMT_FLAG_TEXTURE set. Instead, swallow GL
2046  * errors generated by invalid formats. */
2047  while (gl_info->gl_ops.gl.p_glGetError());
2048 }
#define WINED3DFMT_FLAG_STENCIL
#define GL_RENDERBUFFER
Definition: glext.h:1733
#define GL_DEPTH_ATTACHMENT
Definition: glext.h:1730
struct opengl_funcs gl_ops
#define GL_NEAREST
Definition: gl.h:678
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_STENCIL_ATTACHMENT
Definition: glext.h:1731
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
Definition: glext.h:1234
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
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_ARB
Definition: glext.h:1230
#define GL_COLOR_ATTACHMENT0
Definition: glext.h:1714
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_TEXTURE_3D
Definition: gl.h:1515
smooth NULL
Definition: ftsmooth.c:416
#define GL_FRAMEBUFFER
Definition: glext.h:1732
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define GL_EXTCALL(f)
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
Definition: glext.h:1235
GLbitfield flags
Definition: glext.h:7161
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
Definition: glext.h:1236
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
Definition: glext.h:1237
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
Definition: glext.h:1233
static GLenum wined3d_gl_type_to_enum(enum wined3d_gl_resource_type type)
Definition: utils.c:1900
struct wined3d_fbo_ops fbo_ops
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
Definition: glext.h:1232
#define WINED3DFMT_FLAG_DEPTH

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 4124 of file utils.c.

4125 {
4126  int size;
4127 
4128  if (!separator || buffer->ptr == buffer->str)
4129  separator = "";
4130  size = snprintf(buffer->ptr, buffer->size, "%s%s", separator, str);
4131  if (size == -1 || size >= buffer->size)
4132  {
4133  buffer->size = 0;
4134  strcpy(&buffer->str[ARRAY_SIZE(buffer->str) - 4], "...");
4135  return;
4136  }
4137 
4138  buffer->ptr += size;
4139  buffer->size -= size;
4140 }
static const WCHAR separator[]
Definition: asmname.c:63
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
const WCHAR * str
GLsizeiptr size
Definition: glext.h:5919
#define ARRAY_SIZE(a)
Definition: main.h:24
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

◆ debug_box()

const char* debug_box ( const struct wined3d_box box)

Definition at line 3881 of file utils.c.

3882 {
3883  if (!box)
3884  return "(null)";
3885  return wine_dbg_sprintf("(%u, %u, %u)-(%u, %u, %u)",
3886  box->left, box->top, box->front,
3887  box->right, box->bottom, box->back);
3888 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
Definition: palette.c:467

Referenced by surface_cpu_blt(), surface_cpu_blt_colour_fill(), texture2d_blt(), texture_resource_sub_resource_map(), wined3d_device_copy_sub_resource_region(), wined3d_device_update_sub_resource(), wined3d_resource_map(), wined3d_resource_update_info(), wined3d_texture_add_dirty_region(), wined3d_texture_check_box_dimensions(), wined3d_texture_upload_data(), and wined3d_texture_upload_from_texture().

◆ debug_color()

const char* debug_color ( const struct wined3d_color color)

Definition at line 3890 of file utils.c.

3891 {
3892  if (!color)
3893  return "(null)";
3894  return wine_dbg_sprintf("{%.8e, %.8e, %.8e, %.8e}",
3895  color->r, color->g, color->b, color->a);
3896 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
GLuint color
Definition: glext.h:6243

Referenced by state_ambient(), state_specularenable(), surface_cpu_blt_colour_fill(), wined3d_device_clear(), wined3d_device_clear_rendertarget_view(), wined3d_device_get_material(), wined3d_device_set_light(), and wined3d_format_convert_from_float().

◆ debug_complex_fixup()

static const char* debug_complex_fixup ( enum complex_fixup  fixup)
static

Definition at line 4775 of file utils.c.

4776 {
4777  switch(fixup)
4778  {
4779 #define WINED3D_TO_STR(x) case x: return #x
4785 #undef WINED3D_TO_STR
4786  default:
4787  FIXME("Unrecognized complex fixup %#x\n", fixup);
4788  return "unrecognized";
4789  }
4790 }
#define WINED3D_TO_STR(x)
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by dump_color_fixup_desc().

◆ debug_d3ddeclmethod()

const char* debug_d3ddeclmethod ( enum wined3d_decl_method  method)

Definition at line 4212 of file utils.c.

4213 {
4214  switch (method)
4215  {
4216 #define WINED3DDECLMETHOD_TO_STR(u) case u: return #u
4224 #undef WINED3DDECLMETHOD_TO_STR
4225  default:
4226  FIXME("Unrecognized declaration method %#x.\n", method);
4227  return "unrecognized";
4228  }
4229 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINED3DDECLMETHOD_TO_STR(u)
method
Definition: dragdrop.c:53

Referenced by dump_wined3d_vertex_element().

◆ debug_d3ddeclusage()

const char* debug_d3ddeclusage ( enum wined3d_decl_usage  usage)

Definition at line 4231 of file utils.c.

4232 {
4233  switch (usage)
4234  {
4235 #define WINED3DDECLUSAGE_TO_STR(u) case u: return #u
4250 #undef WINED3DDECLUSAGE_TO_STR
4251  default:
4252  FIXME("Unrecognized %u declaration usage!\n", usage);
4253  return "unrecognized";
4254  }
4255 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINED3DDECLUSAGE_TO_STR(u)
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919

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 4095 of file utils.c.

4096 {
4097  switch (device_type)
4098  {
4099 #define DEVTYPE_TO_STR(dev) case dev: return #dev
4103 #undef DEVTYPE_TO_STR
4104  default:
4105  FIXME("Unrecognized device type %#x.\n", device_type);
4106  return "unrecognized";
4107  }
4108 }
device_type
#define FIXME(fmt,...)
Definition: debug.h:110
#define DEVTYPE_TO_STR(dev)

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 3922 of file utils.c.

3923 {
3924  switch (format_id)
3925  {
3926 #define FMT_TO_STR(format_id) case format_id: return #format_id
4077 #undef FMT_TO_STR
4078  default:
4079  {
4080  char fourcc[5];
4081  fourcc[0] = (char)(format_id);
4082  fourcc[1] = (char)(format_id >> 8);
4083  fourcc[2] = (char)(format_id >> 16);
4084  fourcc[3] = (char)(format_id >> 24);
4085  fourcc[4] = 0;
4086  if (isprint(fourcc[0]) && isprint(fourcc[1]) && isprint(fourcc[2]) && isprint(fourcc[3]))
4087  FIXME("Unrecognized %#x (as fourcc: %s) WINED3DFORMAT!\n", format_id, fourcc);
4088  else
4089  FIXME("Unrecognized %#x WINED3DFORMAT!\n", format_id);
4090  }
4091  return "unrecognized";
4092  }
4093 }