ReactOS  0.4.13-dev-249-gcba1a2f
texture.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for texture.c:

Go to the source code of this file.

Classes

struct  wined3d_texture_idx
 
struct  wined3d_rect_f
 

Macros

#define WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD   50
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (d3d_perf)
 
 WINE_DECLARE_DEBUG_CHANNEL (winediag)
 
static BOOL wined3d_texture_use_pbo (const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
 
static BOOL wined3d_texture_use_immutable_storage (const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
 
void wined3d_texture_translate_drawable_coords (const struct wined3d_texture *texture, HWND window, RECT *rect)
 
GLenum wined3d_texture_get_gl_buffer (const struct wined3d_texture *texture)
 
static DWORD wined3d_resource_access_from_location (DWORD location)
 
static void cube_coords_float (const RECT *r, UINT w, UINT h, struct wined3d_rect_f *f)
 
void texture2d_get_blt_info (const struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *rect, struct wined3d_blt_info *info)
 
static void wined3d_texture_evict_sysmem (struct wined3d_texture *texture)
 
void wined3d_texture_validate_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
 
static void wined3d_texture_set_dirty (struct wined3d_texture *texture)
 
void wined3d_texture_invalidate_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
 
static BOOL wined3d_texture_copy_sysmem_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
BOOL wined3d_texture_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
void wined3d_texture_get_memory (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
 
static void wined3d_texture_remove_buffer_object (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
 
static void wined3d_texture_update_map_binding (struct wined3d_texture *texture)
 
void wined3d_texture_set_map_binding (struct wined3d_texture *texture, DWORD map_binding)
 
static void gltexture_delete (struct wined3d_device *device, const struct wined3d_gl_info *gl_info, struct gl_texture *tex)
 
static unsigned int wined3d_texture_get_gl_sample_count (const struct wined3d_texture *texture)
 
static void wined3d_texture_allocate_gl_mutable_storage (struct wined3d_texture *texture, GLenum gl_internal_format, const struct wined3d_format *format, const struct wined3d_gl_info *gl_info)
 
static void wined3d_texture_allocate_gl_immutable_storage (struct wined3d_texture *texture, GLenum gl_internal_format, const struct wined3d_gl_info *gl_info)
 
static void wined3d_texture_unload_gl_texture (struct wined3d_texture *texture)
 
static void wined3d_texture_sub_resources_destroyed (struct wined3d_texture *texture)
 
static void wined3d_texture_create_dc (void *object)
 
static void wined3d_texture_destroy_dc (void *object)
 
static void wined3d_texture_cleanup (struct wined3d_texture *texture)
 
void wined3d_texture_set_swapchain (struct wined3d_texture *texture, struct wined3d_swapchain *swapchain)
 
void wined3d_texture_bind (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
void wined3d_texture_bind_and_dirtify (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
void wined3d_texture_apply_sampler_desc (struct wined3d_texture *texture, const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context)
 
ULONG CDECL wined3d_texture_incref (struct wined3d_texture *texture)
 
static void wined3d_texture_cleanup_sync (struct wined3d_texture *texture)
 
static void wined3d_texture_destroy_object (void *object)
 
ULONG CDECL wined3d_texture_decref (struct wined3d_texture *texture)
 
struct wined3d_resource *CDECL wined3d_texture_get_resource (struct wined3d_texture *texture)
 
static BOOL color_key_equal (const struct wined3d_color_key *c1, struct wined3d_color_key *c2)
 
void wined3d_texture_load (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
void *CDECL wined3d_texture_get_parent (const struct wined3d_texture *texture)
 
HRESULT wined3d_texture_check_box_dimensions (const struct wined3d_texture *texture, unsigned int level, const struct wined3d_box *box)
 
void CDECL wined3d_texture_get_pitch (const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
 
DWORD CDECL wined3d_texture_set_lod (struct wined3d_texture *texture, DWORD lod)
 
DWORD CDECL wined3d_texture_get_lod (const struct wined3d_texture *texture)
 
DWORD CDECL wined3d_texture_get_level_count (const struct wined3d_texture *texture)
 
HRESULT CDECL wined3d_texture_set_color_key (struct wined3d_texture *texture, DWORD flags, const struct wined3d_color_key *color_key)
 
void wined3d_texture_set_compatible_renderbuffer (struct wined3d_texture *texture, unsigned int level, const struct wined3d_rendertarget_info *rt)
 
HRESULT CDECL wined3d_texture_update_desc (struct wined3d_texture *texture, UINT width, UINT height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, UINT multisample_quality, void *mem, UINT pitch)
 
static void wined3d_texture_prepare_buffer_object (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
 
static void wined3d_texture_force_reload (struct wined3d_texture *texture)
 
void wined3d_texture_prepare_texture (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
static void wined3d_texture_prepare_rb (struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info, BOOL multisample)
 
BOOL wined3d_texture_prepare_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource (struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
HRESULT CDECL wined3d_texture_add_dirty_region (struct wined3d_texture *texture, UINT layer, const struct wined3d_box *dirty_region)
 
void wined3d_texture_upload_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const struct wined3d_format *format, const struct wined3d_box *src_box, const struct wined3d_const_bo_address *data, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, BOOL srgb)
 
static BOOL texture2d_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
struct wined3d_texture *__cdecl wined3d_texture_from_resource (struct wined3d_resource *resource)
 
static ULONG texture_resource_incref (struct wined3d_resource *resource)
 
static ULONG texture_resource_decref (struct wined3d_resource *resource)
 
static void texture_resource_preload (struct wined3d_resource *resource)
 
static void wined3d_texture_unload (struct wined3d_resource *resource)
 
static HRESULT texture_resource_sub_resource_map (struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
 
static HRESULT texture_resource_sub_resource_map_info (struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_info *info, DWORD flags)
 
static HRESULT texture_resource_sub_resource_unmap (struct wined3d_resource *resource, unsigned int sub_resource_idx)
 
static void texture1d_download_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_bo_address *data)
 
static BOOL texture1d_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
static HRESULT wined3d_texture_init (struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_texture_ops *texture_ops)
 
static void texture3d_download_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_bo_address *data)
 
static void texture3d_srgb_transfer (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, BOOL dest_is_srgb)
 
static BOOL texture3d_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
HRESULT CDECL wined3d_texture_blt (struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
 
HRESULT CDECL wined3d_texture_get_overlay_position (const struct wined3d_texture *texture, unsigned int sub_resource_idx, LONG *x, LONG *y)
 
HRESULT CDECL wined3d_texture_set_overlay_position (struct wined3d_texture *texture, unsigned int sub_resource_idx, LONG x, LONG y)
 
HRESULT CDECL wined3d_texture_update_overlay (struct wined3d_texture *texture, unsigned int sub_resource_idx, const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect, DWORD flags)
 
void *CDECL wined3d_texture_get_sub_resource_parent (struct wined3d_texture *texture, unsigned int sub_resource_idx)
 
void CDECL wined3d_texture_set_sub_resource_parent (struct wined3d_texture *texture, unsigned int sub_resource_idx, void *parent)
 
HRESULT CDECL wined3d_texture_get_sub_resource_desc (const struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
 
HRESULT CDECL wined3d_texture_create (struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
 
HRESULT CDECL wined3d_texture_get_dc (struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC *dc)
 
HRESULT CDECL wined3d_texture_release_dc (struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC dc)
 
void wined3d_texture_upload_from_texture (struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box)
 

Variables

static const struct wined3d_texture_ops texture2d_ops
 
static const struct wined3d_resource_ops texture_resource_ops
 
static const struct wined3d_texture_ops texture1d_ops
 
static const struct wined3d_texture_ops texture3d_ops
 

Macro Definition Documentation

◆ WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD

#define WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD   50

Definition at line 31 of file texture.c.

Function Documentation

◆ color_key_equal()

static BOOL color_key_equal ( const struct wined3d_color_key c1,
struct wined3d_color_key c2 
)
static

Definition at line 1255 of file texture.c.

1256 {
1259 }
DWORD color_space_low_value
Definition: wined3d.h:1980
DWORD color_space_high_value
Definition: wined3d.h:1982

Referenced by wined3d_texture_load().

◆ cube_coords_float()

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

Definition at line 144 of file texture.c.

145 {
146  f->l = ((r->left * 2.0f) / w) - 1.0f;
147  f->t = ((r->top * 2.0f) / h) - 1.0f;
148  f->r = ((r->right * 2.0f) / w) - 1.0f;
149  f->b = ((r->bottom * 2.0f) / h) - 1.0f;
150 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLfloat f
Definition: glext.h:7540

Referenced by texture2d_get_blt_info().

◆ gltexture_delete()

static void gltexture_delete ( struct wined3d_device device,
const struct wined3d_gl_info gl_info,
struct gl_texture tex 
)
static

Definition at line 521 of file texture.c.

523 {
525  gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex->name);
526  tex->name = 0;
527 }
struct opengl_funcs gl_ops
Definition: devices.h:37
void context_gl_resource_released(struct wined3d_device *device, GLuint name, BOOL rb_namespace)
Definition: context.c:1089

Referenced by wined3d_texture_unload_gl_texture().

◆ texture1d_download_data()

static void texture1d_download_data ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_context context,
const struct wined3d_bo_address data 
)
static

Definition at line 2439 of file texture.c.

2441 {
2442  const struct wined3d_format *format = texture->resource.format;
2443  const struct wined3d_gl_info *gl_info = context->gl_info;
2444 
2445  if (format->conv_byte_count)
2446  {
2447  FIXME("Attempting to download a converted texture, format %s.\n",
2448  debug_d3dformat(format->id));
2449  return;
2450  }
2451 
2452  if (data->buffer_object)
2453  {
2454  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
2455  checkGLcall("glBindBuffer");
2456  }
2457 
2458  gl_info->gl_ops.gl.p_glGetTexImage(texture->target, sub_resource_idx,
2459  format->glFormat, format->glType, data->addr);
2460  checkGLcall("glGetTexImage");
2461 
2462  if (data->buffer_object)
2463  {
2464  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
2465  checkGLcall("glBindBuffer");
2466  }
2467 }
struct opengl_funcs gl_ops
Definition: http.c:6587
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define checkGLcall(A)
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922

Referenced by texture1d_load_location().

◆ texture1d_load_location()

static BOOL texture1d_load_location ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
DWORD  location 
)
static

Definition at line 2470 of file texture.c.

2472 {
2473  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
2474  unsigned int row_pitch, slice_pitch;
2475 
2476  TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
2477  texture, sub_resource_idx, context, wined3d_debug_location(location));
2478 
2479  if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
2480  return FALSE;
2481 
2482  switch (location)
2483  {
2486  if (sub_resource->locations & WINED3D_LOCATION_SYSMEM)
2487  {
2488  struct wined3d_const_bo_address data = {0, texture->resource.heap_memory};
2489  struct wined3d_box src_box;
2490 
2491  data.addr += sub_resource->offset;
2494  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
2495  wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
2496  wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
2497  &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE);
2498  }
2499  else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
2500  {
2501  struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
2502  struct wined3d_box src_box;
2503 
2506  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
2507  wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
2508  wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
2509  &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE);
2510  }
2511  else
2512  {
2513  FIXME("Implement texture loading from %s.\n", wined3d_debug_location(sub_resource->locations));
2514  return FALSE;
2515  }
2516  break;
2517 
2519  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
2520  {
2521  struct wined3d_bo_address data = {0, texture->resource.heap_memory};
2522 
2523  data.addr += sub_resource->offset;
2524  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
2526  else
2528 
2529  texture1d_download_data(texture, sub_resource_idx, context, &data);
2530  ++texture->download_count;
2531  }
2532  else
2533  {
2534  FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n",
2535  wined3d_debug_location(sub_resource->locations));
2536  return FALSE;
2537  }
2538  break;
2539 
2541  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
2542  {
2543  struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
2544 
2545  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
2547  else
2549 
2550  texture1d_download_data(texture, sub_resource_idx, context, &data);
2551  }
2552  else
2553  {
2554  FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n",
2555  wined3d_debug_location(sub_resource->locations));
2556  return FALSE;
2557  }
2558  break;
2559 
2560  default:
2561  FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location),
2562  wined3d_debug_location(sub_resource->locations));
2563  return FALSE;
2564  }
2565 
2566  return TRUE;
2567 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const struct wined3d_format *format, const struct wined3d_box *src_box, const struct wined3d_const_bo_address *data, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, BOOL srgb)
Definition: texture.c:1887
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1800
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_LOCATION_SYSMEM
static void wined3d_texture_get_level_box(const struct wined3d_texture *texture, unsigned int level, struct wined3d_box *box)
#define WINED3D_LOCATION_TEXTURE_RGB
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1064
#define WINED3D_LOCATION_TEXTURE_SRGB
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364
static void texture1d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_bo_address *data)
Definition: texture.c:2439

◆ texture2d_get_blt_info()

void texture2d_get_blt_info ( const struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const RECT rect,
struct wined3d_blt_info info 
)

Definition at line 152 of file texture.c.

154 {
155  struct wined3d_vec3 *coords = info->texcoords;
156  struct wined3d_rect_f f;
157  unsigned int level;
158  GLenum target;
159  GLsizei w, h;
160 
161  level = sub_resource_idx % texture->level_count;
165 
166  switch (target)
167  {
168  default:
169  FIXME("Unsupported texture target %#x.\n", target);
170  /* Fall back to GL_TEXTURE_2D */
171  case GL_TEXTURE_2D:
172  info->bind_target = GL_TEXTURE_2D;
173  coords[0].x = (float)rect->left / w;
174  coords[0].y = (float)rect->top / h;
175  coords[0].z = 0.0f;
176 
177  coords[1].x = (float)rect->right / w;
178  coords[1].y = (float)rect->top / h;
179  coords[1].z = 0.0f;
180 
181  coords[2].x = (float)rect->left / w;
182  coords[2].y = (float)rect->bottom / h;
183  coords[2].z = 0.0f;
184 
185  coords[3].x = (float)rect->right / w;
186  coords[3].y = (float)rect->bottom / h;
187  coords[3].z = 0.0f;
188  break;
189 
191  info->bind_target = GL_TEXTURE_RECTANGLE_ARB;
192  coords[0].x = rect->left; coords[0].y = rect->top; coords[0].z = 0.0f;
193  coords[1].x = rect->right; coords[1].y = rect->top; coords[1].z = 0.0f;
194  coords[2].x = rect->left; coords[2].y = rect->bottom; coords[2].z = 0.0f;
195  coords[3].x = rect->right; coords[3].y = rect->bottom; coords[3].z = 0.0f;
196  break;
197 
199  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
200  cube_coords_float(rect, w, h, &f);
201 
202  coords[0].x = 1.0f; coords[0].y = -f.t; coords[0].z = -f.l;
203  coords[1].x = 1.0f; coords[1].y = -f.t; coords[1].z = -f.r;
204  coords[2].x = 1.0f; coords[2].y = -f.b; coords[2].z = -f.l;
205  coords[3].x = 1.0f; coords[3].y = -f.b; coords[3].z = -f.r;
206  break;
207 
209  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
210  cube_coords_float(rect, w, h, &f);
211 
212  coords[0].x = -1.0f; coords[0].y = -f.t; coords[0].z = f.l;
213  coords[1].x = -1.0f; coords[1].y = -f.t; coords[1].z = f.r;
214  coords[2].x = -1.0f; coords[2].y = -f.b; coords[2].z = f.l;
215  coords[3].x = -1.0f; coords[3].y = -f.b; coords[3].z = f.r;
216  break;
217 
219  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
220  cube_coords_float(rect, w, h, &f);
221 
222  coords[0].x = f.l; coords[0].y = 1.0f; coords[0].z = f.t;
223  coords[1].x = f.r; coords[1].y = 1.0f; coords[1].z = f.t;
224  coords[2].x = f.l; coords[2].y = 1.0f; coords[2].z = f.b;
225  coords[3].x = f.r; coords[3].y = 1.0f; coords[3].z = f.b;
226  break;
227 
229  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
230  cube_coords_float(rect, w, h, &f);
231 
232  coords[0].x = f.l; coords[0].y = -1.0f; coords[0].z = -f.t;
233  coords[1].x = f.r; coords[1].y = -1.0f; coords[1].z = -f.t;
234  coords[2].x = f.l; coords[2].y = -1.0f; coords[2].z = -f.b;
235  coords[3].x = f.r; coords[3].y = -1.0f; coords[3].z = -f.b;
236  break;
237 
239  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
240  cube_coords_float(rect, w, h, &f);
241 
242  coords[0].x = f.l; coords[0].y = -f.t; coords[0].z = 1.0f;
243  coords[1].x = f.r; coords[1].y = -f.t; coords[1].z = 1.0f;
244  coords[2].x = f.l; coords[2].y = -f.b; coords[2].z = 1.0f;
245  coords[3].x = f.r; coords[3].y = -f.b; coords[3].z = 1.0f;
246  break;
247 
249  info->bind_target = GL_TEXTURE_CUBE_MAP_ARB;
250  cube_coords_float(rect, w, h, &f);
251 
252  coords[0].x = -f.l; coords[0].y = -f.t; coords[0].z = -1.0f;
253  coords[1].x = -f.r; coords[1].y = -f.t; coords[1].z = -1.0f;
254  coords[2].x = -f.l; coords[2].y = -f.b; coords[2].z = -1.0f;
255  coords[3].x = -f.r; coords[3].y = -f.b; coords[3].z = -1.0f;
256  break;
257  }
258 }
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
GLint level
Definition: gl.h:1546
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
Definition: gl.h:1795
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z
Definition: gl.h:1794
GLuint coords
Definition: glext.h:7368
& rect
Definition: startmenu.cpp:1413
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
int GLsizei
Definition: gl.h:160
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X
Definition: gl.h:1790
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
Definition: gl.h:1793
GLfloat f
Definition: glext.h:7540
static void cube_coords_float(const RECT *r, UINT w, UINT h, struct wined3d_rect_f *f)
Definition: texture.c:144
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y
Definition: gl.h:1792
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X
Definition: gl.h:1791
#define GL_TEXTURE_2D
Definition: gl.h:645
GLenum target
Definition: glext.h:7315
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by context_draw_shaded_quad(), and context_draw_textured_quad().

◆ texture2d_load_location()

static BOOL texture2d_load_location ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
DWORD  location 
)
static

Definition at line 2104 of file texture.c.

2106 {
2107  TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
2108  texture, sub_resource_idx, context, wined3d_debug_location(location));
2109 
2110  switch (location)
2111  {
2115  return texture2d_load_sysmem(texture, sub_resource_idx, context, location);
2116 
2118  return texture2d_load_drawable(texture, sub_resource_idx, context);
2119 
2122  return texture2d_load_renderbuffer(texture, sub_resource_idx, context, location);
2123 
2126  return texture2d_load_texture(texture, sub_resource_idx, context,
2128 
2129  default:
2130  ERR("Don't know how to handle location %#x.\n", location);
2131  return FALSE;
2132  }
2133 }
Definition: http.c:6587
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
#define WINED3D_LOCATION_RB_MULTISAMPLE
#define WINED3D_LOCATION_RB_RESOLVED
#define WINED3D_LOCATION_DRAWABLE
BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD dst_location)
Definition: surface.c:1794
#define TRACE(s)
Definition: solgame.cpp:4
BOOL texture2d_load_renderbuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD dst_location)
Definition: surface.c:2037
#define WINED3D_LOCATION_USER_MEMORY
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_LOCATION_SYSMEM
#define ERR(fmt,...)
Definition: debug.h:109
#define WINED3D_LOCATION_TEXTURE_RGB
BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, BOOL srgb)
Definition: surface.c:1888
BOOL texture2d_load_drawable(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context)
Definition: surface.c:1841
#define WINED3D_LOCATION_TEXTURE_SRGB

◆ texture3d_download_data()

static void texture3d_download_data ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_context context,
const struct wined3d_bo_address data 
)
static

Definition at line 2915 of file texture.c.

2917 {
2918  const struct wined3d_format *format = texture->resource.format;
2919  const struct wined3d_gl_info *gl_info = context->gl_info;
2920 
2921  if (format->conv_byte_count)
2922  {
2923  FIXME("Attempting to download a converted volume, format %s.\n",
2924  debug_d3dformat(format->id));
2925  return;
2926  }
2927 
2928  if (data->buffer_object)
2929  {
2930  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
2931  checkGLcall("glBindBuffer");
2932  }
2933 
2934  gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_3D, sub_resource_idx,
2935  format->glFormat, format->glType, data->addr);
2936  checkGLcall("glGetTexImage");
2937 
2938  if (data->buffer_object)
2939  {
2940  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
2941  checkGLcall("glBindBuffer");
2942  }
2943 
2944 }
struct opengl_funcs gl_ops
Definition: http.c:6587
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define FIXME(fmt,...)
Definition: debug.h:110
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define checkGLcall(A)
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922

Referenced by texture3d_load_location(), and texture3d_srgb_transfer().

◆ texture3d_load_location()

static BOOL texture3d_load_location ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
DWORD  location 
)
static

Definition at line 2978 of file texture.c.

2980 {
2981  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
2982  unsigned int row_pitch, slice_pitch;
2983 
2984  if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
2985  return FALSE;
2986 
2987  switch (location)
2988  {
2991  if (sub_resource->locations & WINED3D_LOCATION_SYSMEM)
2992  {
2993  struct wined3d_const_bo_address data = {0, texture->resource.heap_memory};
2994  struct wined3d_box src_box;
2995 
2996  data.addr += sub_resource->offset;
2999  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
3000  wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
3001  wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
3002  &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE);
3003  }
3004  else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
3005  {
3006  struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
3007  struct wined3d_box src_box;
3008 
3011  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
3012  wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
3013  wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
3014  &src_box, &data, row_pitch, slice_pitch, 0, 0, 0, FALSE);
3015  }
3016  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3017  {
3018  texture3d_srgb_transfer(texture, sub_resource_idx, context, TRUE);
3019  }
3020  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_SRGB)
3021  {
3022  texture3d_srgb_transfer(texture, sub_resource_idx, context, FALSE);
3023  }
3024  else
3025  {
3026  FIXME("Implement texture loading from %s.\n", wined3d_debug_location(sub_resource->locations));
3027  return FALSE;
3028  }
3029  break;
3030 
3032  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
3033  {
3034  struct wined3d_bo_address data = {0, texture->resource.heap_memory};
3035 
3036  data.addr += sub_resource->offset;
3037  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3039  else
3041 
3042  texture3d_download_data(texture, sub_resource_idx, context, &data);
3043  ++texture->download_count;
3044  }
3045  else
3046  {
3047  FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n",
3048  wined3d_debug_location(sub_resource->locations));
3049  return FALSE;
3050  }
3051  break;
3052 
3054  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
3055  {
3056  struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
3057 
3058  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3060  else
3062 
3063  texture3d_download_data(texture, sub_resource_idx, context, &data);
3064  }
3065  else
3066  {
3067  FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n",
3068  wined3d_debug_location(sub_resource->locations));
3069  return FALSE;
3070  }
3071  break;
3072 
3073  default:
3074  FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location),
3075  wined3d_debug_location(sub_resource->locations));
3076  return FALSE;
3077  }
3078 
3079  return TRUE;
3080 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, BOOL dest_is_srgb)
Definition: texture.c:2947
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const struct wined3d_format *format, const struct wined3d_box *src_box, const struct wined3d_const_bo_address *data, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, BOOL srgb)
Definition: texture.c:1887
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1800
GLenum GLuint texture
Definition: glext.h:6295
static void texture3d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_bo_address *data)
Definition: texture.c:2915
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_LOCATION_SYSMEM
static void wined3d_texture_get_level_box(const struct wined3d_texture *texture, unsigned int level, struct wined3d_box *box)
#define WINED3D_LOCATION_TEXTURE_RGB
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1064
#define WINED3D_LOCATION_TEXTURE_SRGB
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364

◆ texture3d_srgb_transfer()

static void texture3d_srgb_transfer ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
BOOL  dest_is_srgb 
)
static

Definition at line 2947 of file texture.c.

2949 {
2950  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
2951  unsigned int row_pitch, slice_pitch;
2952  struct wined3d_bo_address data;
2953  struct wined3d_box src_box;
2954 
2955  /* Optimisations are possible, but the effort should be put into either
2956  * implementing EXT_SRGB_DECODE in the driver or finding out why we
2957  * picked the wrong copy for the original upload and fixing that.
2958  *
2959  * Also keep in mind that we want to avoid using resource.heap_memory
2960  * for DEFAULT pool surfaces. */
2961  WARN_(d3d_perf)("Performing slow rgb/srgb volume transfer.\n");
2962  data.buffer_object = 0;
2963  if (!(data.addr = heap_alloc(sub_resource->size)))
2964  return;
2965 
2966  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
2967  wined3d_texture_get_level_box(texture, sub_resource_idx % texture->level_count, &src_box);
2969  texture3d_download_data(texture, sub_resource_idx, context, &data);
2971  wined3d_texture_upload_data(texture, sub_resource_idx, context, texture->resource.format,
2972  &src_box, wined3d_const_bo_address(&data), row_pitch, slice_pitch, 0, 0, 0, FALSE);
2973 
2974  heap_free(data.addr);
2975 }
Definition: http.c:6587
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, const struct wined3d_format *format, const struct wined3d_box *src_box, const struct wined3d_const_bo_address *data, unsigned int src_row_pitch, unsigned int src_slice_pitch, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, BOOL srgb)
Definition: texture.c:1887
GLenum GLuint texture
Definition: glext.h:6295
static void texture3d_download_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_bo_address *data)
Definition: texture.c:2915
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void wined3d_texture_get_level_box(const struct wined3d_texture *texture, unsigned int level, struct wined3d_box *box)
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1064
#define WARN_(ch,...)
Definition: debug.h:157
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by texture3d_load_location().

◆ texture_resource_decref()

static ULONG texture_resource_decref ( struct wined3d_resource resource)
static

Definition at line 2150 of file texture.c.

2151 {
2153 }
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1219

◆ texture_resource_incref()

static ULONG texture_resource_incref ( struct wined3d_resource resource)
static

Definition at line 2145 of file texture.c.

2146 {
2148 }
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:1190

◆ texture_resource_preload()

static void texture_resource_preload ( struct wined3d_resource resource)
static

Definition at line 2155 of file texture.c.

2156 {
2158  struct wined3d_context *context;
2159 
2160  context = context_acquire(resource->device, NULL, 0);
2163 }
Definition: http.c:6587
#define WINED3D_TEXTURE_IS_SRGB
smooth NULL
Definition: ftsmooth.c:416
void context_release(struct wined3d_context *context)
Definition: context.c:1559
GLenum GLuint texture
Definition: glext.h:6295
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1262

◆ texture_resource_sub_resource_map()

static HRESULT texture_resource_sub_resource_map ( struct wined3d_resource resource,
unsigned int  sub_resource_idx,
struct wined3d_map_desc map_desc,
const struct wined3d_box box,
DWORD  flags 
)
static

Definition at line 2222 of file texture.c.

2224 {
2225  const struct wined3d_format *format = resource->format;
2226  struct wined3d_texture_sub_resource *sub_resource;
2227  struct wined3d_device *device = resource->device;
2228  unsigned int fmt_flags = resource->format_flags;
2229  struct wined3d_context *context = NULL;
2230  struct wined3d_texture *texture;
2231  struct wined3d_bo_address data;
2232  unsigned int texture_level;
2233  BYTE *base_memory;
2234  BOOL ret;
2235 
2236  TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
2237  resource, sub_resource_idx, map_desc, debug_box(box), flags);
2238 
2240  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2241  return E_INVALIDARG;
2242 
2243  texture_level = sub_resource_idx % texture->level_count;
2244  if (box && FAILED(wined3d_texture_check_box_dimensions(texture, texture_level, box)))
2245  {
2246  WARN("Map box is invalid.\n");
2247  if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
2248  || resource->type != WINED3D_RTYPE_TEXTURE_2D)
2249  return WINED3DERR_INVALIDCALL;
2250  }
2251 
2252  if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
2253  {
2254  WARN("DC is in use.\n");
2255  return WINED3DERR_INVALIDCALL;
2256  }
2257 
2258  if (sub_resource->map_count)
2259  {
2260  WARN("Sub-resource is already mapped.\n");
2261  return WINED3DERR_INVALIDCALL;
2262  }
2263 
2264  if (device->d3d_initialized)
2266 
2267  if (flags & WINED3D_MAP_DISCARD)
2268  {
2269  TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n",
2270  wined3d_debug_location(resource->map_binding));
2271  if ((ret = wined3d_texture_prepare_location(texture, sub_resource_idx, context, resource->map_binding)))
2272  wined3d_texture_validate_location(texture, sub_resource_idx, resource->map_binding);
2273  }
2274  else
2275  {
2276  if (resource->usage & WINED3DUSAGE_DYNAMIC)
2277  WARN_(d3d_perf)("Mapping a dynamic texture without WINED3D_MAP_DISCARD.\n");
2278  ret = wined3d_texture_load_location(texture, sub_resource_idx, context, resource->map_binding);
2279  }
2280 
2281  if (!ret)
2282  {
2283  ERR("Failed to prepare location.\n");
2285  return E_OUTOFMEMORY;
2286  }
2287 
2288  if (flags & WINED3D_MAP_WRITE
2290  wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
2291 
2292  wined3d_texture_get_memory(texture, sub_resource_idx, &data, resource->map_binding);
2293  base_memory = context_map_bo_address(context, &data, sub_resource->size, GL_PIXEL_UNPACK_BUFFER, flags);
2294  TRACE("Base memory pointer %p.\n", base_memory);
2295 
2296  if (context)
2298 
2299  if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
2300  {
2301  map_desc->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count;
2302  map_desc->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * map_desc->row_pitch;
2303  }
2304  else
2305  {
2306  wined3d_texture_get_pitch(texture, texture_level, &map_desc->row_pitch, &map_desc->slice_pitch);
2307  }
2308 
2309  if (!box)
2310  {
2311  map_desc->data = base_memory;
2312  }
2313  else
2314  {
2316  {
2317  /* Compressed textures are block based, so calculate the offset of
2318  * the block that contains the top-left pixel of the mapped box. */
2319  map_desc->data = base_memory
2320  + (box->front * map_desc->slice_pitch)
2321  + ((box->top / format->block_height) * map_desc->row_pitch)
2322  + ((box->left / format->block_width) * format->block_byte_count);
2323  }
2324  else
2325  {
2326  map_desc->data = base_memory
2327  + (box->front * map_desc->slice_pitch)
2328  + (box->top * map_desc->row_pitch)
2329  + (box->left * format->byte_count);
2330  }
2331  }
2332 
2333  if (texture->swapchain && texture->swapchain->front_buffer == texture)
2334  {
2335  RECT *r = &texture->swapchain->front_buffer_update;
2336 
2337  if (!box)
2338  SetRect(r, 0, 0, resource->width, resource->height);
2339  else
2340  SetRect(r, box->left, box->top, box->right, box->bottom);
2341  TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
2342  }
2343 
2344  ++resource->map_count;
2345  ++sub_resource->map_count;
2346 
2347  TRACE("Returning memory %p, row pitch %u, slice pitch %u.\n",
2348  map_desc->data, map_desc->row_pitch, map_desc->slice_pitch);
2349 
2350  return WINED3D_OK;
2351 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:916
#define WARN(fmt,...)
Definition: debug.h:111
#define WINED3DFMT_FLAG_BROKEN_PITCH
#define WINED3DFMT_FLAG_BLOCKS
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:3881
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture, unsigned int level, const struct wined3d_box *box)
Definition: texture.c:1324
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:56
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define E_INVALIDARG
Definition: ddrawi.h:101
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:436
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define WINED3D_TEXTURE_DC_IN_USE
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1800
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:944
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:286
GLenum GLuint texture
Definition: glext.h:6295
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define WINED3D_MAP_NO_DIRTY_UPDATE
Definition: wined3d.h:946
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
int ret
#define WINED3D_MAP_WRITE
Definition: wined3d.h:947
unsigned char BYTE
Definition: mem.h:68
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2569
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:1849
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:380
#define WARN_(ch,...)
Definition: debug.h:157
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364
Definition: palette.c:467

◆ texture_resource_sub_resource_map_info()

static HRESULT texture_resource_sub_resource_map_info ( struct wined3d_resource resource,
unsigned int  sub_resource_idx,
struct wined3d_map_info info,
DWORD  flags 
)
static

Definition at line 2353 of file texture.c.

2355 {
2356  const struct wined3d_format *format = resource->format;
2357  struct wined3d_texture_sub_resource *sub_resource;
2358  unsigned int fmt_flags = resource->format_flags;
2359  struct wined3d_texture *texture;
2360  unsigned int texture_level;
2361 
2363  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2364  return E_INVALIDARG;
2365 
2366  texture_level = sub_resource_idx % texture->level_count;
2367 
2368  if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
2369  {
2370  info->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count;
2371  info->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * info->row_pitch;
2372  }
2373  else
2374  {
2375  wined3d_texture_get_pitch(texture, texture_level, &info->row_pitch, &info->slice_pitch);
2376  }
2377 
2378  info->size = info->slice_pitch * wined3d_texture_get_level_depth(texture, texture_level);
2379 
2380  return WINED3D_OK;
2381 }
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WINED3DFMT_FLAG_BROKEN_PITCH
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define E_INVALIDARG
Definition: ddrawi.h:101
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:1849
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364

◆ texture_resource_sub_resource_unmap()

static HRESULT texture_resource_sub_resource_unmap ( struct wined3d_resource resource,
unsigned int  sub_resource_idx 
)
static

Definition at line 2383 of file texture.c.

2384 {
2385  struct wined3d_texture_sub_resource *sub_resource;
2386  struct wined3d_device *device = resource->device;
2387  struct wined3d_context *context = NULL;
2388  struct wined3d_texture *texture;
2389  struct wined3d_bo_address data;
2390 
2391  TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
2392 
2394  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2395  return E_INVALIDARG;
2396 
2397  if (!sub_resource->map_count)
2398  {
2399  WARN("Trying to unmap unmapped sub-resource.\n");
2400  if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
2401  return WINED3D_OK;
2402  return WINEDDERR_NOTLOCKED;
2403  }
2404 
2405  if (device->d3d_initialized)
2407 
2408  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
2410 
2411  if (context)
2413 
2414  if (texture->swapchain && texture->swapchain->front_buffer == texture)
2415  {
2416  if (!(sub_resource->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)))
2417  texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(texture->swapchain);
2418  }
2419 
2420  --sub_resource->map_count;
2421  if (!--resource->map_count && texture->update_map_binding)
2423 
2424  return WINED3D_OK;
2425 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2598
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
Definition: devices.h:37
#define E_INVALIDARG
Definition: ddrawi.h:101
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:436
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define WINED3D_TEXTURE_DC_IN_USE
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
Definition: texture.c:486
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
#define WINEDDERR_NOTLOCKED
Definition: wined3d.h:50
#define WINED3D_LOCATION_TEXTURE_RGB
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:1849

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/2]

WINE_DECLARE_DEBUG_CHANNEL ( d3d_perf  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/2]

WINE_DECLARE_DEBUG_CHANNEL ( winediag  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_resource_access_from_location()

static DWORD wined3d_resource_access_from_location ( DWORD  location)
static

Definition at line 119 of file texture.c.

120 {
121  switch (location)
122  {
124  return 0;
125 
129 
137 
138  default:
139  FIXME("Unhandled location %#x.\n", location);
140  return 0;
141  }
142 }
#define WINED3D_LOCATION_BUFFER
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:56
#define WINED3D_LOCATION_RB_MULTISAMPLE
#define FIXME(fmt,...)
Definition: debug.h:110
#define WINED3D_LOCATION_RB_RESOLVED
#define WINED3D_LOCATION_DRAWABLE
#define WINED3D_LOCATION_USER_MEMORY
#define WINED3D_LOCATION_SYSMEM
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define WINED3D_LOCATION_TEXTURE_RGB
#define WINED3D_LOCATION_DISCARDED
#define WINED3D_LOCATION_TEXTURE_SRGB

Referenced by wined3d_texture_load_location().

◆ wined3d_texture_add_dirty_region()

HRESULT CDECL wined3d_texture_add_dirty_region ( struct wined3d_texture texture,
UINT  layer,
const struct wined3d_box dirty_region 
)

Definition at line 1865 of file texture.c.

1867 {
1868  TRACE("texture %p, layer %u, dirty_region %s.\n", texture, layer, debug_box(dirty_region));
1869 
1870  if (layer >= texture->layer_count)
1871  {
1872  WARN("Invalid layer %u specified.\n", layer);
1873  return WINED3DERR_INVALIDCALL;
1874  }
1875 
1876  if (dirty_region)
1877  WARN("Ignoring dirty_region %s.\n", debug_box(dirty_region));
1878 
1880 
1881  return WINED3D_OK;
1882 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define WARN(fmt,...)
Definition: debug.h:111
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:3881
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, struct wined3d_texture *texture, unsigned int layer)
Definition: cs.c:2351

Referenced by d3d8_texture_2d_AddDirtyRect(), d3d8_texture_3d_AddDirtyBox(), d3d8_texture_cube_AddDirtyRect(), d3d9_texture_2d_AddDirtyRect(), d3d9_texture_3d_AddDirtyBox(), and d3d9_texture_cube_AddDirtyRect().

◆ wined3d_texture_allocate_gl_immutable_storage()

static void wined3d_texture_allocate_gl_immutable_storage ( struct wined3d_texture texture,
GLenum  gl_internal_format,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 620 of file texture.c.

622 {
626 
627  switch (texture->target)
628  {
629  case GL_TEXTURE_3D:
630  GL_EXTCALL(glTexStorage3D(texture->target, texture->level_count,
631  gl_internal_format, width, height, wined3d_texture_get_level_depth(texture, 0)));
632  break;
633  case GL_TEXTURE_2D_ARRAY:
634  GL_EXTCALL(glTexStorage3D(texture->target, texture->level_count,
635  gl_internal_format, width, height, texture->layer_count));
636  break;
638  GL_EXTCALL(glTexStorage2DMultisample(texture->target, samples,
639  gl_internal_format, width, height, GL_FALSE));
640  break;
642  GL_EXTCALL(glTexStorage3DMultisample(texture->target, samples,
643  gl_internal_format, width, height, texture->layer_count, GL_FALSE));
644  break;
645  case GL_TEXTURE_1D_ARRAY:
646  GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count,
647  gl_internal_format, width, texture->layer_count));
648  break;
649  case GL_TEXTURE_1D:
650  GL_EXTCALL(glTexStorage1D(texture->target, texture->level_count, gl_internal_format, width));
651  break;
652  default:
653  GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count,
654  gl_internal_format, width, height));
655  break;
656  }
657 
658  checkGLcall("allocate immutable storage");
659 }
GLsizei samples
Definition: glext.h:7006
GLint GLint GLsizei width
Definition: gl.h:1546
static unsigned int wined3d_texture_get_gl_sample_count(const struct wined3d_texture *texture)
Definition: texture.c:529
#define GL_FALSE
Definition: gl.h:173
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_1D
Definition: gl.h:644
int GLsizei
Definition: gl.h:160
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define checkGLcall(A)
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by wined3d_texture_prepare_texture().

◆ wined3d_texture_allocate_gl_mutable_storage()

static void wined3d_texture_allocate_gl_mutable_storage ( struct wined3d_texture texture,
GLenum  gl_internal_format,
const struct wined3d_format format,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 563 of file texture.c.

566 {
567  unsigned int level, level_count, layer, layer_count;
569  GLenum target;
570 
571  level_count = texture->level_count;
572  if (texture->target == GL_TEXTURE_1D_ARRAY || texture->target == GL_TEXTURE_2D_ARRAY)
573  layer_count = 1;
574  else
575  layer_count = texture->layer_count;
576 
577  for (layer = 0; layer < layer_count; ++layer)
578  {
580 
581  for (level = 0; level < level_count; ++level)
582  {
585  if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
586  {
587  height *= format->height_scale.numerator;
588  height /= format->height_scale.denominator;
589  }
590 
591  TRACE("texture %p, layer %u, level %u, target %#x, width %u, height %u.\n",
593 
595  {
597  GL_EXTCALL(glTexImage3D(target, level, gl_internal_format, width, height,
598  target == GL_TEXTURE_2D_ARRAY ? texture->layer_count : depth, 0,
599  format->glFormat, format->glType, NULL));
600  checkGLcall("glTexImage3D");
601  }
602  else if (target == GL_TEXTURE_1D)
603  {
604  gl_info->gl_ops.gl.p_glTexImage1D(target, level, gl_internal_format,
605  width, 0, format->glFormat, format->glType, NULL);
606  }
607  else
608  {
609  gl_info->gl_ops.gl.p_glTexImage2D(target, level, gl_internal_format, width,
610  target == GL_TEXTURE_1D_ARRAY ? texture->layer_count : height, 0,
611  format->glFormat, format->glType, NULL);
612  checkGLcall("glTexImage2D");
613  }
614  }
615  }
616 }
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
GLint level
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
struct opengl_funcs gl_ops
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
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_1D
Definition: gl.h:644
int GLsizei
Definition: gl.h:160
#define GL_TEXTURE_3D
Definition: gl.h:1515
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
static unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture, unsigned int level)
unsigned int GLenum
Definition: gl.h:150
#define WINED3DFMT_FLAG_HEIGHT_SCALE
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define checkGLcall(A)
GLenum target
Definition: glext.h:7315
static unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by wined3d_texture_prepare_texture().

◆ wined3d_texture_apply_sampler_desc()

void wined3d_texture_apply_sampler_desc ( struct wined3d_texture texture,
const struct wined3d_sampler_desc sampler_desc,
const struct wined3d_context context 
)

Definition at line 1092 of file texture.c.

1094 {
1095  const struct wined3d_gl_info *gl_info = context->gl_info;
1096  GLenum target = texture->target;
1097  struct gl_texture *gl_tex;
1098  DWORD state;
1099 
1100  TRACE("texture %p, sampler_desc %p, context %p.\n", texture, sampler_desc, context);
1101 
1103 
1104  state = sampler_desc->address_u;
1105  if (state != gl_tex->sampler_desc.address_u)
1106  {
1107  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S,
1109  gl_tex->sampler_desc.address_u = state;
1110  }
1111 
1112  state = sampler_desc->address_v;
1113  if (state != gl_tex->sampler_desc.address_v)
1114  {
1115  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T,
1117  gl_tex->sampler_desc.address_v = state;
1118  }
1119 
1120  state = sampler_desc->address_w;
1121  if (state != gl_tex->sampler_desc.address_w)
1122  {
1123  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_R,
1125  gl_tex->sampler_desc.address_w = state;
1126  }
1127 
1128  if (memcmp(gl_tex->sampler_desc.border_color, sampler_desc->border_color,
1129  sizeof(gl_tex->sampler_desc.border_color)))
1130  {
1131  gl_info->gl_ops.gl.p_glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, &sampler_desc->border_color[0]);
1132  memcpy(gl_tex->sampler_desc.border_color, sampler_desc->border_color,
1133  sizeof(gl_tex->sampler_desc.border_color));
1134  }
1135 
1136  state = sampler_desc->mag_filter;
1137  if (state != gl_tex->sampler_desc.mag_filter)
1138  {
1139  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(state));
1140  gl_tex->sampler_desc.mag_filter = state;
1141  }
1142 
1143  if (sampler_desc->min_filter != gl_tex->sampler_desc.min_filter
1144  || sampler_desc->mip_filter != gl_tex->sampler_desc.mip_filter)
1145  {
1146  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
1147  wined3d_gl_min_mip_filter(sampler_desc->min_filter, sampler_desc->mip_filter));
1148  gl_tex->sampler_desc.min_filter = sampler_desc->min_filter;
1149  gl_tex->sampler_desc.mip_filter = sampler_desc->mip_filter;
1150  }
1151 
1152  state = sampler_desc->max_anisotropy;
1153  if (state != gl_tex->sampler_desc.max_anisotropy)
1154  {
1156  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY, state);
1157  else
1158  WARN("Anisotropic filtering not supported.\n");
1159  gl_tex->sampler_desc.max_anisotropy = state;
1160  }
1161 
1162  if (!sampler_desc->srgb_decode != !gl_tex->sampler_desc.srgb_decode
1163  && (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
1164  && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
1165  {
1166  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
1167  sampler_desc->srgb_decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT);
1168  gl_tex->sampler_desc.srgb_decode = sampler_desc->srgb_decode;
1169  }
1170 
1171  if (!sampler_desc->compare != !gl_tex->sampler_desc.compare)
1172  {
1173  if (sampler_desc->compare)
1174  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
1175  else
1176  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
1177  gl_tex->sampler_desc.compare = sampler_desc->compare;
1178  }
1179 
1180  checkGLcall("Texture parameter application");
1181 
1182  if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
1183  {
1184  gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
1186  checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
1187  }
1188 }
struct opengl_funcs gl_ops
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define GL_TEXTURE_LOD_BIAS_EXT
Definition: glext.h:3362
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
Definition: http.c:6587
#define WARN(fmt,...)
Definition: debug.h:111
GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP+1]
#define GL_TEXTURE_WRAP_R
Definition: gl.h:1518
#define WINED3D_TEXTURE_IS_SRGB
BOOL supported[WINED3D_GL_EXT_COUNT]
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define TRACE(s)
Definition: solgame.cpp:4
#define GL_DECODE_EXT
Definition: glext.h:5290
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_COMPARE_MODE_ARB
Definition: glext.h:1371
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GL_NONE
Definition: gl.h:465
struct wined3d_sampler_desc sampler_desc
static struct gl_texture * wined3d_texture_get_gl_texture(struct wined3d_texture *texture, BOOL srgb)
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_TEXTURE_MAX_ANISOTROPY
Definition: wgl.h:4357
#define checkGLcall(A)
#define GL_TEXTURE_BORDER_COLOR
Definition: gl.h:656
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
#define GL_TEXTURE_FILTER_CONTROL_EXT
Definition: glext.h:3361
GLenum target
Definition: glext.h:7315
#define WINED3D_SRGB_READ_WRITE_CONTROL
Definition: wined3d.h:1326
#define GL_COMPARE_R_TO_TEXTURE_ARB
Definition: glext.h:1373
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291

Referenced by wined3d_sampler_bind().

◆ wined3d_texture_bind()

void wined3d_texture_bind ( struct wined3d_texture texture,
struct wined3d_context context,
BOOL  srgb 
)

Definition at line 925 of file texture.c.

927 {
928  const struct wined3d_gl_info *gl_info = context->gl_info;
929  const struct wined3d_format *format = texture->resource.format;
930  const struct color_fixup_desc fixup = format->color_fixup;
931  struct gl_texture *gl_tex;
932  GLenum target;
933 
934  TRACE("texture %p, context %p, srgb %#x.\n", texture, context, srgb);
935 
937  srgb = FALSE;
938 
939  /* sRGB mode cache for preload() calls outside drawprim. */
940  if (srgb)
942  else
943  texture->flags &= ~WINED3D_TEXTURE_IS_SRGB;
944 
945  gl_tex = wined3d_texture_get_gl_texture(texture, srgb);
946  target = texture->target;
947 
948  if (gl_tex->name)
949  {
951  return;
952  }
953 
954  gl_info->gl_ops.gl.p_glGenTextures(1, &gl_tex->name);
955  checkGLcall("glGenTextures");
956  TRACE("Generated texture %d.\n", gl_tex->name);
957 
958  if (!gl_tex->name)
959  {
960  ERR("Failed to generate a texture name.\n");
961  return;
962  }
963 
964  /* Initialise the state of the texture object to the OpenGL defaults, not
965  * the wined3d defaults. */
966  gl_tex->sampler_desc.address_u = WINED3D_TADDRESS_WRAP;
967  gl_tex->sampler_desc.address_v = WINED3D_TADDRESS_WRAP;
968  gl_tex->sampler_desc.address_w = WINED3D_TADDRESS_WRAP;
969  memset(gl_tex->sampler_desc.border_color, 0, sizeof(gl_tex->sampler_desc.border_color));
970  gl_tex->sampler_desc.mag_filter = WINED3D_TEXF_LINEAR;
971  gl_tex->sampler_desc.min_filter = WINED3D_TEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
972  gl_tex->sampler_desc.mip_filter = WINED3D_TEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
973  gl_tex->sampler_desc.lod_bias = 0.0f;
974  gl_tex->sampler_desc.min_lod = -1000.0f;
975  gl_tex->sampler_desc.max_lod = 1000.0f;
976  gl_tex->sampler_desc.max_anisotropy = 1;
977  gl_tex->sampler_desc.compare = FALSE;
978  gl_tex->sampler_desc.comparison_func = WINED3D_CMP_LESSEQUAL;
979  if (context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
980  gl_tex->sampler_desc.srgb_decode = TRUE;
981  else
982  gl_tex->sampler_desc.srgb_decode = srgb;
983  gl_tex->base_level = 0;
985 
987 
988  /* For a new texture we have to set the texture levels after binding the
989  * texture. Beware that texture rectangles do not support mipmapping, but
990  * set the maxmiplevel if we're relying on the partial
991  * GL_ARB_texture_non_power_of_two emulation with texture rectangles.
992  * (I.e., do not care about cond_np2 here, just look for
993  * GL_TEXTURE_RECTANGLE_ARB.) */
995  {
996  TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", texture->level_count - 1);
997  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count - 1);
998  checkGLcall("glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count)");
999  }
1000 
1002  {
1003  /* Cubemaps are always set to clamp, regardless of the sampler state. */
1004  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1005  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1006  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
1007  }
1008 
1009  if (texture->flags & WINED3D_TEXTURE_COND_NP2)
1010  {
1011  /* Conditinal non power of two textures use a different clamping
1012  * default. If we're using the GL_WINE_normalized_texrect partial
1013  * driver emulation, we're dealing with a GL_TEXTURE_2D texture which
1014  * has the address mode set to repeat - something that prevents us
1015  * from hitting the accelerated codepath. Thus manually set the GL
1016  * state. The same applies to filtering. Even if the texture has only
1017  * one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
1018  * fallback on macos. */
1019  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1020  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1021  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1022  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1023  checkGLcall("glTexParameteri");
1024  gl_tex->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP;
1025  gl_tex->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP;
1026  gl_tex->sampler_desc.mag_filter = WINED3D_TEXF_POINT;
1027  gl_tex->sampler_desc.min_filter = WINED3D_TEXF_POINT;
1028  gl_tex->sampler_desc.mip_filter = WINED3D_TEXF_NONE;
1029  }
1030 
1032  {
1033  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY);
1034  checkGLcall("glTexParameteri(GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY)");
1035  }
1036 
1037  if (!is_identity_fixup(fixup) && can_use_texture_swizzle(gl_info, format))
1038  {
1039  static const GLenum swizzle_source[] =
1040  {
1041  GL_ZERO, /* CHANNEL_SOURCE_ZERO */
1042  GL_ONE, /* CHANNEL_SOURCE_ONE */
1043  GL_RED, /* CHANNEL_SOURCE_X */
1044  GL_GREEN, /* CHANNEL_SOURCE_Y */
1045  GL_BLUE, /* CHANNEL_SOURCE_Z */
1046  GL_ALPHA, /* CHANNEL_SOURCE_W */
1047  };
1048  struct
1049  {
1050  GLint x, y, z, w;
1051  }
1052  swizzle;
1053 
1054  swizzle.x = swizzle_source[fixup.x_source];
1055  swizzle.y = swizzle_source[fixup.y_source];
1056  swizzle.z = swizzle_source[fixup.z_source];
1057  swizzle.w = swizzle_source[fixup.w_source];
1058  gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, &swizzle.x);
1059  checkGLcall("glTexParameteriv(GL_TEXTURE_SWIZZLE_RGBA)");
1060  }
1061 }
unsigned short x_source
#define TRUE
Definition: types.h:120
#define GL_RED
Definition: gl.h:480
#define GL_ONE
Definition: gl.h:375
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
static BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context, const struct wined3d_texture *texture)
struct opengl_funcs gl_ops
#define GL_CLAMP_TO_EDGE
Definition: gl.h:1481
Definition: http.c:6587
unsigned short w_source
#define GL_NEAREST
Definition: gl.h:678
#define GL_ALPHA
Definition: gl.h:483
static BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info, const struct wined3d_format *format)
#define GL_TEXTURE_SWIZZLE_RGBA
Definition: glext.h:2032
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
Definition: context.c:2503
#define WINED3D_TEXTURE_COND_NP2
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
#define GL_TEXTURE_WRAP_R
Definition: gl.h:1518
#define WINED3D_TEXTURE_IS_SRGB
#define GL_ZERO
Definition: gl.h:374
static void wined3d_texture_set_dirty(struct wined3d_texture *texture)
Definition: texture.c:305
BOOL supported[WINED3D_GL_EXT_COUNT]
GLdouble GLdouble z
Definition: glext.h:5874
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
unsigned short z_source
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
#define GL_BLUE
Definition: gl.h:482
struct wined3d_sampler_desc sampler_desc
static struct gl_texture * wined3d_texture_get_gl_texture(struct wined3d_texture *texture, BOOL srgb)
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_GREEN
Definition: gl.h:481
unsigned int base_level
#define checkGLcall(A)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum target
Definition: glext.h:7315
#define GL_DEPTH_TEXTURE_MODE_ARB
Definition: glext.h:1367
GLuint GLenum swizzle
Definition: glext.h:9511
int GLint
Definition: gl.h:156
#define memset(x, y, z)
Definition: compat.h:39
#define GL_INTENSITY
Definition: gl.h:747
unsigned short y_source
#define GL_TEXTURE_MAX_LEVEL
Definition: gl.h:1504

Referenced by sampler(), wined3d_shader_resource_view_bind(), and wined3d_texture_bind_and_dirtify().

◆ wined3d_texture_bind_and_dirtify()

void wined3d_texture_bind_and_dirtify ( struct wined3d_texture texture,
struct wined3d_context context,
BOOL  srgb 
)

Definition at line 1064 of file texture.c.

1066 {
1067  /* We don't need a specific texture unit, but after binding the texture
1068  * the current unit is dirty. Read the unit back instead of switching to
1069  * 0, this avoids messing around with the state manager's GL states. The
1070  * current texture unit should always be a valid one.
1071  *
1072  * To be more specific, this is tricky because we can implicitly be
1073  * called from sampler() in state.c. This means we can't touch anything
1074  * other than whatever happens to be the currently active texture, or we
1075  * would risk marking already applied sampler states dirty again. */
1076  if (context->active_texture < ARRAY_SIZE(context->rev_tex_unit_map))
1077  {
1078  DWORD active_sampler = context->rev_tex_unit_map[context->active_texture];
1079  if (active_sampler != WINED3D_UNMAPPED_STAGE)
1081  }
1082  /* FIXME: Ideally we'd only do this when touching a binding that's used by
1083  * a shader. */
1086 
1088 }
Definition: http.c:6587
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1638
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:1628
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATE_COMPUTE_SHADER_RESOURCE_BINDING
#define WINED3D_UNMAPPED_STAGE
#define STATE_SAMPLER(num)
#define ARRAY_SIZE(a)
Definition: main.h:24
void wined3d_texture_bind(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:925

Referenced by shader_resource_view_generate_mipmaps(), surface_convert_format(), texture1d_load_location(), texture2d_load_fb_texture(), texture2d_load_sysmem(), texture2d_load_texture(), texture3d_load_location(), texture3d_srgb_transfer(), wined3d_cs_exec_blt_sub_resource(), wined3d_cs_exec_update_sub_resource(), wined3d_texture_prepare_texture(), and wined3d_texture_upload_from_texture().

◆ wined3d_texture_blt()

HRESULT CDECL wined3d_texture_blt ( struct wined3d_texture dst_texture,
unsigned int  dst_sub_resource_idx,
const RECT dst_rect,
struct wined3d_texture src_texture,
unsigned int  src_sub_resource_idx,
const RECT src_rect,
DWORD  flags,
const struct wined3d_blt_fx fx,
enum wined3d_texture_filter_type  filter 
)

Definition at line 3087 of file texture.c.

3090 {
3091  struct wined3d_box src_box = {src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1};
3092  struct wined3d_box dst_box = {dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, 0, 1};
3093  unsigned int dst_format_flags, src_format_flags = 0;
3094  HRESULT hr;
3095 
3096  TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_rect %s, src_texture %p, "
3097  "src_sub_resource_idx %u, src_rect %s, flags %#x, fx %p, filter %s.\n",
3098  dst_texture, dst_sub_resource_idx, wine_dbgstr_rect(dst_rect), src_texture,
3099  src_sub_resource_idx, wine_dbgstr_rect(src_rect), flags, fx, debug_d3dtexturefiltertype(filter));
3100 
3101  if (dst_sub_resource_idx >= dst_texture->level_count * dst_texture->layer_count
3102  || dst_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
3103  return WINED3DERR_INVALIDCALL;
3104 
3105  if (src_sub_resource_idx >= src_texture->level_count * src_texture->layer_count
3106  || src_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
3107  return WINED3DERR_INVALIDCALL;
3108 
3109  dst_format_flags = dst_texture->resource.format_flags;
3111  dst_sub_resource_idx % dst_texture->level_count, &dst_box)))
3112  return hr;
3113 
3114  src_format_flags = src_texture->resource.format_flags;
3116  src_sub_resource_idx % src_texture->level_count, &src_box)))
3117  return hr;
3118 
3119  if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
3120  || src_texture->sub_resources[src_sub_resource_idx].map_count)
3121  {
3122  WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
3123  return WINEDDERR_SURFACEBUSY;
3124  }
3125 
3126  if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
3127  != (dst_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
3128  {
3129  WARN("Rejecting depth/stencil blit between incompatible formats.\n");
3130  return WINED3DERR_INVALIDCALL;
3131  }
3132 
3133  wined3d_cs_emit_blt_sub_resource(dst_texture->resource.device->cs, &dst_texture->resource, dst_sub_resource_idx,
3134  &dst_box, &src_texture->resource, src_sub_resource_idx, &src_box, flags, fx, filter);
3135 
3136  return WINED3D_OK;
3137 }
#define WINED3DFMT_FLAG_STENCIL
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
LONG top
Definition: windef.h:292
struct wined3d_resource resource
LONG left
Definition: windef.h:291
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture, unsigned int level, const struct wined3d_box *box)
Definition: texture.c:1324
LONG right
Definition: windef.h:293
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
const char * debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type)
Definition: utils.c:4480
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
GLfixed fx
Definition: tritemp.h:482
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
#define WINEDDERR_SURFACEBUSY
Definition: wined3d.h:51
LONG bottom
Definition: windef.h:294
#define WINED3DFMT_FLAG_DEPTH
void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: cs.c:2174
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by copy_mipmap_chain(), d3d8_device_CopyRects(), d3d9_device_GetRenderTargetData(), d3d9_device_StretchRect(), d3d_texture2_Load(), ddraw_surface7_BltFast(), ddraw_surface_blt(), ddraw_surface_update_frontbuffer(), swapchain_gl_present(), wined3d_device_resolve_sub_resource(), and wined3d_swapchain_get_front_buffer_data().

◆ wined3d_texture_check_box_dimensions()

HRESULT wined3d_texture_check_box_dimensions ( const struct wined3d_texture texture,
unsigned int  level,
const struct wined3d_box box 
)

Definition at line 1324 of file texture.c.

1326 {
1327  const struct wined3d_format *format = texture->resource.format;
1328  unsigned int width_mask, height_mask, width, height, depth;
1329 
1333 
1334  if (box->left >= box->right || box->right > width
1335  || box->top >= box->bottom || box->bottom > height
1336  || box->front >= box->back || box->back > depth)
1337  {
1338  WARN("Box %s is invalid.\n", debug_box(box));
1339  return WINEDDERR_INVALIDRECT;
1340  }
1341 
1342  if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
1343  {
1344  /* This assumes power of two block sizes, but NPOT block sizes would
1345  * be silly anyway.
1346  *
1347  * This also assumes that the format's block depth is 1. */
1348  width_mask = format->block_width - 1;
1349  height_mask = format->block_height - 1;
1350 
1351  if ((box->left & width_mask) || (box->top & height_mask)
1352  || (box->right & width_mask && box->right != width)
1353  || (box->bottom & height_mask && box->bottom != height))
1354  {
1355  WARN("Box %s is misaligned for %ux%u blocks.\n",
1356  debug_box(box), format->block_width, format->block_height);
1357  return WINED3DERR_INVALIDCALL;
1358  }
1359  }
1360 
1361  return WINED3D_OK;
1362 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
GLint level
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WARN(fmt,...)
Definition: debug.h:111
#define WINED3DFMT_FLAG_BLOCKS
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
const char * debug_box(const struct wined3d_box *box)
Definition: utils.c:3881
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define WINEDDERR_INVALIDRECT
Definition: wined3d.h:52
Definition: palette.c:467

Referenced by texture_resource_sub_resource_map(), wined3d_device_clear_rendertarget_view(), wined3d_device_copy_sub_resource_region(), and wined3d_texture_blt().

◆ wined3d_texture_cleanup()

static void wined3d_texture_cleanup ( struct wined3d_texture texture)
static

Definition at line 838 of file texture.c.

839 {
840  unsigned int sub_count = texture->level_count * texture->layer_count;
841  struct wined3d_device *device = texture->resource.device;
842  struct wined3d_renderbuffer_entry *entry, *entry2;
843  const struct wined3d_gl_info *gl_info = NULL;
844  struct wined3d_context *context = NULL;
845  struct wined3d_dc_info *dc_info;
846  GLuint buffer_object;
847  unsigned int i;
848 
849  TRACE("texture %p.\n", texture);
850 
851  for (i = 0; i < sub_count; ++i)
852  {
853  if (!(buffer_object = texture->sub_resources[i].buffer_object))
854  continue;
855 
856  TRACE("Deleting buffer object %u.\n", buffer_object);
857 
858  /* We may not be able to get a context in wined3d_texture_cleanup() in
859  * general, but if a buffer object was previously created we can. */
860  if (!context)
861  {
863  gl_info = context->gl_info;
864  }
865 
866  GL_EXTCALL(glDeleteBuffers(1, &buffer_object));
867  }
868 
869  if (!context && !list_empty(&texture->renderbuffers))
870  {
872  gl_info = context->gl_info;
873  }
874 
875  LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &texture->renderbuffers, struct wined3d_renderbuffer_entry, entry)
876  {
877  TRACE("Deleting renderbuffer %u.\n", entry->id);
879  gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
880  heap_free(entry);
881  }
882 
883  if (context)
885 
886  if ((dc_info = texture->dc_info))
887  {
888  for (i = 0; i < sub_count; ++i)
889  {
890  if (dc_info[i].dc)
891  {
892  struct wined3d_texture_idx texture_idx = {texture, i};
893 
894  wined3d_texture_destroy_dc(&texture_idx);
895  }
896  }
897  heap_free(dc_info);
898  }
899 
900  if (texture->overlay_info)
901  {
902  for (i = 0; i < sub_count; ++i)
903  {
904  struct wined3d_overlay_info *info = &texture->overlay_info[i];
905  struct wined3d_overlay_info *overlay, *cur;
906 
907  list_remove(&info->entry);
908  LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &info->overlays, struct wined3d_overlay_info, entry)
909  {
910  list_remove(&overlay->entry);
911  }
912  }
913  heap_free(texture->overlay_info);
914  }
916 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static void wined3d_texture_destroy_dc(void *object)
Definition: texture.c:796
static void wined3d_texture_unload_gl_texture(struct wined3d_texture *texture)
Definition: texture.c:661
HDC dc
Definition: cylfrac.c:34
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: devices.h:37
smooth NULL
Definition: ftsmooth.c:416
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define GL_EXTCALL(f)
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
uint32_t entry
Definition: isohybrid.c:63
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
unsigned int GLuint
Definition: gl.h:159
struct wined3d_fbo_ops fbo_ops
void context_gl_resource_released(struct wined3d_device *device, GLuint name, BOOL rb_namespace)
Definition: context.c:1089
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by wined3d_texture_cleanup_sync(), and wined3d_texture_destroy_object().

◆ wined3d_texture_cleanup_sync()

static void wined3d_texture_cleanup_sync ( struct wined3d_texture texture)
static

Definition at line 1205 of file texture.c.

1206 {
1208  resource_cleanup(&texture->resource);
1209  wined3d_resource_wait_idle(&texture->resource);
1211 }
static void wined3d_resource_wait_idle(struct wined3d_resource *resource)
static void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture)
Definition: texture.c:703
static void wined3d_texture_cleanup(struct wined3d_texture *texture)
Definition: texture.c:838
GLenum GLuint texture
Definition: glext.h:6295
void resource_cleanup(struct wined3d_resource *resource)
Definition: resource.c:227

Referenced by wined3d_texture_create(), and wined3d_texture_init().

◆ wined3d_texture_copy_sysmem_location()

static BOOL wined3d_texture_copy_sysmem_location ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_context context,
DWORD  location 
)
static

Definition at line 335 of file texture.c.

337 {
338  unsigned int size = texture->sub_resources[sub_resource_idx].size;
339  struct wined3d_device *device = texture->resource.device;
340  const struct wined3d_gl_info *gl_info;
341  struct wined3d_bo_address dst, src;
342 
343  if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
344  return FALSE;
345 
346  wined3d_texture_get_memory(texture, sub_resource_idx, &dst, location);
347  wined3d_texture_get_memory(texture, sub_resource_idx, &src,
348  texture->sub_resources[sub_resource_idx].locations);
349 
350  if (dst.buffer_object)
351  {
353  gl_info = context->gl_info;
354  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, dst.buffer_object));
355  GL_EXTCALL(glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, size, src.addr));
356  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
357  checkGLcall("PBO upload");
359  return TRUE;
360  }
361 
362  if (src.buffer_object)
363  {
365  gl_info = context->gl_info;
366  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, src.buffer_object));
367  GL_EXTCALL(glGetBufferSubData(GL_PIXEL_PACK_BUFFER, 0, size, dst.addr));
368  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
369  checkGLcall("PBO download");
371  return TRUE;
372  }
373 
374  memcpy(dst.addr, src.addr, size);
375  return TRUE;
376 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
Definition: devices.h:37
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:436
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define GL_EXTCALL(f)
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1800
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint texture
Definition: glext.h:6295
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
GLenum GLenum dst
Definition: glext.h:6340
#define checkGLcall(A)
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476

Referenced by wined3d_texture_load_location().

◆ wined3d_texture_create()

HRESULT CDECL wined3d_texture_create ( struct wined3d_device device,
const struct wined3d_resource_desc desc,
UINT  layer_count,
UINT  level_count,
DWORD  flags,
const struct wined3d_sub_resource_data data,
void parent,
const struct wined3d_parent_ops parent_ops,
struct wined3d_texture **  texture 
)

Definition at line 3326 of file texture.c.

3329 {
3330  const struct wined3d_texture_ops *texture_ops;
3331  struct wined3d_texture *object;
3332  HRESULT hr;
3333 
3334  TRACE("device %p, desc %p, layer_count %u, level_count %u, flags %#x, data %p, "
3335  "parent %p, parent_ops %p, texture %p.\n",
3336  device, desc, layer_count, level_count, flags, data, parent, parent_ops, texture);
3337 
3338  if (!layer_count)
3339  {
3340  WARN("Invalid layer count.\n");
3341  return E_INVALIDARG;
3342  }
3343  if ((desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) && layer_count != 6)
3344  {
3345  ERR("Invalid layer count %u for legacy cubemap.\n", layer_count);
3346  layer_count = 6;
3347  }
3348 
3349  if (!level_count)
3350  {
3351  WARN("Invalid level count.\n");
3352  return WINED3DERR_INVALIDCALL;
3353  }
3354 
3355  if (desc->multisample_type != WINED3D_MULTISAMPLE_NONE)
3356  {
3357  const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info,
3358  desc->format, desc->usage);
3359 
3360  if (desc->multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE
3361  && desc->multisample_quality >= wined3d_popcount(format->multisample_types))
3362  {
3363  WARN("Unsupported quality level %u requested for WINED3D_MULTISAMPLE_NON_MASKABLE.\n",
3364  desc->multisample_quality);
3365  return WINED3DERR_NOTAVAILABLE;
3366  }
3367  if (desc->multisample_type != WINED3D_MULTISAMPLE_NON_MASKABLE
3368  && (!(format->multisample_types & 1u << (desc->multisample_type - 1))
3369  || desc->multisample_quality))
3370  {
3371  WARN("Unsupported multisample type %u quality %u requested.\n", desc->multisample_type,
3372  desc->multisample_quality);
3373  return WINED3DERR_NOTAVAILABLE;
3374  }
3375  }
3376 
3377  switch (desc->resource_type)
3378  {
3380  texture_ops = &texture1d_ops;
3381  break;
3383  texture_ops = &texture2d_ops;
3384  break;
3386  texture_ops = &texture3d_ops;
3387  break;
3388  default:
3389  ERR("Invalid resource type %s.\n", debug_d3dresourcetype(desc->resource_type));
3390  return WINED3DERR_INVALIDCALL;
3391  }
3392 
3393  if (!(object = heap_alloc_zero(FIELD_OFFSET(struct wined3d_texture,
3394  sub_resources[level_count * layer_count]))))
3395  return E_OUTOFMEMORY;
3396 
3397  if (FAILED(hr = wined3d_texture_init(object, desc, layer_count,
3398  level_count, flags, device, parent, parent_ops, texture_ops)))
3399  {
3400  WARN("Failed to initialize texture, returning %#x.\n", hr);
3401  heap_free(object);
3402  return hr;
3403  }
3404 
3405  /* FIXME: We'd like to avoid ever allocating system memory for the texture
3406  * in this case. */
3407  if (data)
3408  {
3409  unsigned int sub_count = level_count * layer_count;
3410  unsigned int i;
3411 
3412  for (i = 0; i < sub_count; ++i)
3413  {
3414  if (!data[i].data)
3415  {
3416  WARN("Invalid sub-resource data specified for sub-resource %u.\n", i);
3418  heap_free(object);
3419  return E_INVALIDARG;
3420  }
3421  }
3422 
3423  for (i = 0; i < sub_count; ++i)
3424  {
3426  i, NULL, data[i].data, data[i].row_pitch, data[i].slice_pitch, 0);
3427  }
3428  }
3429 
3430  TRACE("Created texture %p.\n", object);
3431  *texture = object;
3432 
3433  return WINED3D_OK;
3434 }
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 WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
HRESULT hr
Definition: shlfolder.c:183
static const struct wined3d_texture_ops texture2d_ops
Definition: texture.c:2135
static const struct wined3d_texture_ops texture1d_ops
Definition: texture.c:2569
static unsigned int wined3d_popcount(unsigned int x)
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_texture_ops *texture_ops)
Definition: texture.c:2574
const struct wined3d_format * wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
Definition: utils.c:3773
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
Definition: texture.c:1205
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 E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define E_INVALIDARG
Definition: ddrawi.h:101
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define WINED3DUSAGE_LEGACY_CUBEMAP
Definition: wined3d.h:926
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2677
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define ERR(fmt,...)
Definition: debug.h:109
static const struct wined3d_texture_ops texture3d_ops
Definition: texture.c:3082
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:46
void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch, unsigned int depth_pitch, unsigned int flags)
Definition: device.c:4321
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4271
void * object
Definition: jmemsys.h:48
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by arbfp_blitter_blit(), cubetexture_init(), d3d8_device_create_surface(), d3d9_device_create_surface(), ddraw_surface_create(), device_load_logo(), device_parent_create_swapchain_texture(), ffp_blitter_blit(), glsl_blitter_blit(), surface_convert_format(), texture_init(), volumetexture_init(), and wined3d_device_create_cursor_texture().

◆ wined3d_texture_create_dc()

static void wined3d_texture_create_dc ( void object)
static

Definition at line 721 of file texture.c.

722 {
723  const struct wined3d_texture_idx *idx = object;
724  struct wined3d_context *context = NULL;
725  unsigned int sub_resource_idx, level;
726  const struct wined3d_format *format;
727  unsigned int row_pitch, slice_pitch;
728  struct wined3d_texture *texture;
729  struct wined3d_dc_info *dc_info;
730  struct wined3d_bo_address data;
732  struct wined3d_device *device;
734 
735  TRACE("texture %p, sub_resource_idx %u.\n", idx->texture, idx->sub_resource_idx);
736 
737  texture = idx->texture;
738  sub_resource_idx = idx->sub_resource_idx;
739  level = sub_resource_idx % texture->level_count;
740  device = texture->resource.device;
741 
742  format = texture->resource.format;
743  if (!format->ddi_format)
744  {
745  WARN("Cannot create a DC for format %s.\n", debug_d3dformat(format->id));
746  return;
747  }
748 
749  if (!texture->dc_info)
750  {
751  unsigned int sub_count = texture->level_count * texture->layer_count;
752 
753  if (!(texture->dc_info = heap_calloc(sub_count, sizeof(*texture->dc_info))))
754  {
755  ERR("Failed to allocate DC info.\n");
756  return;
757  }
758  }
759 
760  if (device->d3d_initialized)
762 
763  wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
764  wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
765  wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch);
766  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
768  texture->sub_resources[sub_resource_idx].size,
770 
771  if (context)
773 
774  desc.Format = format->ddi_format;
777  desc.Pitch = row_pitch;
778  desc.hDeviceDc = CreateCompatibleDC(NULL);
779  desc.pColorTable = NULL;
780 
782  DeleteDC(desc.hDeviceDc);
783  if (status)
784  {
785  WARN("Failed to create DC, status %#x.\n", status);
786  return;
787  }
788 
789  dc_info = &texture->dc_info[sub_resource_idx];
790  dc_info->dc = desc.hDc;
791  dc_info->bitmap = desc.hBitmap;
792 
793  TRACE("Created DC %p, bitmap %p for texture %p, %u.\n", dc_info->dc, dc_info->bitmap, texture, sub_resource_idx);
794 }
GLint level
Definition: gl.h:1546
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
unsigned int idx
Definition: utils.c:41
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:436
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_MAP_READ
Definition: wined3d.h:948
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_MAP_WRITE
Definition: wined3d.h:947
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
BOOL WINAPI DeleteDC(_In_ HDC)
DWORD APIENTRY D3DKMTCreateDCFromMemory(_Inout_ D3DKMT_CREATEDCFROMMEMORY *)
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2569
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:380
unsigned int sub_resource_idx
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
static SERVICE_STATUS status
Definition: service.c:31
void * object
Definition: jmemsys.h:48
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1364
Definition: ps.c:97

Referenced by wined3d_texture_get_dc(), wined3d_texture_init(), and wined3d_texture_update_desc().

◆ wined3d_texture_decref()

ULONG CDECL wined3d_texture_decref ( struct wined3d_texture texture)

Definition at line 1219 of file texture.c.

1220 {
1221  ULONG refcount;
1222 
1223  TRACE("texture %p, swapchain %p.\n", texture, texture->swapchain);
1224 
1225  if (texture->swapchain)
1226  return wined3d_swapchain_decref(texture->swapchain);
1227 
1228  refcount = InterlockedDecrement(&texture->resource.ref);
1229  TRACE("%p decreasing refcount to %u.\n", texture, refcount);
1230 
1231  if (!refcount)
1232  {
1233  /* Wait for the texture to become idle if it's using user memory,
1234  * since the application is allowed to free that memory once the
1235  * texture is destroyed. Note that this implies that
1236  * wined3d_texture_destroy_object() can't access that memory either. */
1237  if (texture->user_memory)
1238  wined3d_resource_wait_idle(&texture->resource);
1240  texture->resource.parent_ops->wined3d_object_destroyed(texture->resource.parent);
1241  resource_cleanup(&texture->resource);
1243  }
1244 
1245  return refcount;
1246 }
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:113
static void wined3d_texture_destroy_object(void *object)
Definition: texture.c:1213
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1907
static void wined3d_resource_wait_idle(struct wined3d_resource *resource)
static void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture)
Definition: texture.c:703
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
void resource_cleanup(struct wined3d_resource *resource)
Definition: resource.c:227

Referenced by arbfp_blitter_blit(), d3d8_device_create_surface(), d3d8_surface_Release(), d3d8_texture_2d_Release(), d3d8_texture_3d_Release(), d3d8_texture_cube_Release(), d3d9_device_create_surface(), d3d9_surface_Release(), d3d9_texture_cleanup(), ddraw_surface_cleanup(), ddraw_surface_create(), device_load_logo(), ffp_blitter_blit(), glsl_blitter_blit(), state_unbind_resources(), surface_cpu_blt(), swapchain_cleanup(), swapchain_init(), texture_resource_decref(), wined3d_device_reset(), wined3d_device_set_cursor_properties(), wined3d_device_set_texture(), wined3d_device_uninit_3d(), and wined3d_stateblock_capture().

◆ wined3d_texture_destroy_dc()

static void wined3d_texture_destroy_dc ( void object)
static

Definition at line 796 of file texture.c.

797 {
798  const struct wined3d_texture_idx *idx = object;
799  D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
800  struct wined3d_context *context = NULL;
801  struct wined3d_texture *texture;
802  struct wined3d_dc_info *dc_info;
803  struct wined3d_bo_address data;
804  unsigned int sub_resource_idx;
805  struct wined3d_device *device;
807 
808  texture = idx->texture;
809  sub_resource_idx = idx->sub_resource_idx;
810  device = texture->resource.device;
811  dc_info = &texture->dc_info[sub_resource_idx];
812 
813  if (!dc_info->dc)
814  {
815  ERR("Sub-resource {%p, %u} has no DC.\n", texture, sub_resource_idx);
816  return;
817  }
818 
819  TRACE("dc %p, bitmap %p.\n", dc_info->dc, dc_info->bitmap);
820 
821  destroy_desc.hDc = dc_info->dc;
822  destroy_desc.hBitmap = dc_info->bitmap;
823  if ((status = D3DKMTDestroyDCFromMemory(&destroy_desc)))
824  ERR("Failed to destroy dc, status %#x.\n", status);
825  dc_info->dc = NULL;
826  dc_info->bitmap = NULL;
827 
828  if (device->d3d_initialized)
830 
831  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
833 
834  if (context)
836 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2598
Definition: http.c:6587
LONG NTSTATUS
Definition: precomp.h:26
Definition: devices.h:37
unsigned int idx
Definition: utils.c:41
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_bo_address *data, DWORD locations)
Definition: texture.c:436
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
DWORD APIENTRY D3DKMTDestroyDCFromMemory(_In_ CONST D3DKMT_DESTROYDCFROMMEMORY *)
static SERVICE_STATUS status
Definition: service.c:31
void * object
Definition: jmemsys.h:48
Definition: ps.c:97

Referenced by wined3d_texture_cleanup(), wined3d_texture_release_dc(), and wined3d_texture_update_desc().

◆ wined3d_texture_destroy_object()

static void wined3d_texture_destroy_object ( void object)
static

Definition at line 1213 of file texture.c.

1214 {
1215  wined3d_texture_cleanup(object);
1216  heap_free(object);
1217 }
static void wined3d_texture_cleanup(struct wined3d_texture *texture)
Definition: texture.c:838
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by wined3d_texture_decref().

◆ wined3d_texture_evict_sysmem()

static void wined3d_texture_evict_sysmem ( struct wined3d_texture texture)
static

Definition at line 260 of file texture.c.

261 {
262  struct wined3d_texture_sub_resource *sub_resource;
263  unsigned int i, sub_count;
264 
266  || texture->download_count > WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD)
267  {
268  TRACE("Not evicting system memory for texture %p.\n", texture);
269  return;
270  }
271 
272  TRACE("Evicting system memory for texture %p.\n", texture);
273 
274  sub_count = texture->level_count * texture->layer_count;
275  for (i = 0; i < sub_count; ++i)
276  {
277  sub_resource = &texture->sub_resources[i];
278  if (sub_resource->locations == WINED3D_LOCATION_SYSMEM)
279  ERR("WINED3D_LOCATION_SYSMEM is the only location for sub-resource %u of texture %p.\n",
280  i, texture);
281  sub_resource->locations &= ~WINED3D_LOCATION_SYSMEM;
282  }
284 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_LOCATION_SYSMEM
#define ERR(fmt,...)
Definition: debug.h:109
#define WINED3D_TEXTURE_DYNAMIC_MAP_THRESHOLD
Definition: texture.c:31
#define WINED3D_TEXTURE_CONVERTED
#define WINED3D_TEXTURE_PIN_SYSMEM
void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
Definition: resource.c:497

Referenced by wined3d_texture_validate_location().

◆ wined3d_texture_force_reload()

static void wined3d_texture_force_reload ( struct wined3d_texture texture)
static

Definition at line 1690 of file texture.c.

1691 {
1692  unsigned int sub_count = texture->level_count * texture->layer_count;
1693  unsigned int i;
1694 
1697  texture->async.flags &= ~WINED3D_TEXTURE_ASYNC_COLOR_KEY;
1698  for (i = 0; i < sub_count; ++i)
1699  {
1702  }
1703 }
#define WINED3D_TEXTURE_ASYNC_COLOR_KEY
#define WINED3D_TEXTURE_SRGB_ALLOCATED
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
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_TEXTURE_RGB_ALLOCATED
#define WINED3D_TEXTURE_CONVERTED
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
#define WINED3D_LOCATION_TEXTURE_RGB
#define WINED3D_LOCATION_TEXTURE_SRGB

Referenced by wined3d_texture_prepare_texture(), and wined3d_texture_unload().

◆ wined3d_texture_from_resource()

◆ wined3d_texture_get_dc()

HRESULT CDECL wined3d_texture_get_dc ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
HDC dc 
)

Definition at line 3436 of file texture.c.

3437 {
3438  struct wined3d_device *device = texture->resource.device;
3439  struct wined3d_texture_sub_resource *sub_resource;
3440  struct wined3d_dc_info *dc_info;
3441 
3442  TRACE("texture %p, sub_resource_idx %u, dc %p.\n", texture, sub_resource_idx, dc);
3443 
3444  if (!(texture->flags & WINED3D_TEXTURE_GET_DC))
3445  {
3446  WARN("Texture does not support GetDC\n");
3447  /* Don't touch the DC */
3448  return WINED3DERR_INVALIDCALL;
3449  }
3450 
3451  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
3452  return WINED3DERR_INVALIDCALL;
3453 
3454  if (texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
3455  {
3456  WARN("Not supported on %s resources.\n", debug_d3dresourcetype(texture->resource.type));
3457  return WINED3DERR_INVALIDCALL;
3458  }
3459 
3460  if (texture->resource.map_count && !(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
3461  return WINED3DERR_INVALIDCALL;
3462 
3463  if (!(dc_info = texture->dc_info) || !dc_info[sub_resource_idx].dc)
3464  {
3465  struct wined3d_texture_idx texture_idx = {texture, sub_resource_idx};
3466 
3468  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
3469  if (!(dc_info = texture->dc_info) || !dc_info[sub_resource_idx].dc)
3470  return WINED3DERR_INVALIDCALL;
3471  }
3472 
3473  if (!(texture->flags & WINED3D_TEXTURE_GET_DC_LENIENT))
3475  ++texture->resource.map_count;
3476  ++sub_resource->map_count;
3477 
3478  *dc = dc_info[sub_resource_idx].dc;
3479  TRACE("Returning dc %p.\n", *dc);
3480 
3481  return WINED3D_OK;
3482 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
unsigned int sub_resource_idx
Definition: texture.c:36
static void wined3d_texture_create_dc(void *object)
Definition: texture.c:721
#define WARN(fmt,...)
Definition: debug.h:111
HDC dc
Definition: cylfrac.c:34
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1912
#define WINED3D_TEXTURE_GET_DC_LENIENT
Definition: devices.h:37
#define WINED3D_TEXTURE_GET_DC
#define WINED3D_TEXTURE_DC_IN_USE
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:1849
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4271

Referenced by d3d9_surface_GetDC(), ddraw_surface7_GetDC(), ddraw_surface_update_frontbuffer(), and device_load_logo().

◆ wined3d_texture_get_gl_buffer()

GLenum wined3d_texture_get_gl_buffer ( const struct wined3d_texture texture)

Definition at line 91 of file texture.c.

92 {
93  const struct wined3d_swapchain *swapchain = texture->swapchain;
94 
95  TRACE("texture %p.\n", texture);
96 
97  if (!swapchain)
98  {
99  ERR("Texture %p is not part of a swapchain.\n", texture);
100  return GL_NONE;
101  }
102 
103  if (texture == swapchain->front_buffer)
104  {
105  TRACE("Returning GL_FRONT.\n");
106  return GL_FRONT;
107  }
108 
109  if (texture == swapchain->back_buffers[0])
110  {
111  TRACE("Returning GL_BACK.\n");
112  return GL_BACK;
113  }
114 
115  FIXME("Higher back buffer, returning GL_BACK.\n");
116  return GL_BACK;
117 }
struct wined3d_texture * front_buffer
#define GL_BACK
Definition: gl.h:271
struct wined3d_texture ** back_buffers
#define GL_FRONT
Definition: gl.h:270
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define GL_NONE
Definition: gl.h:465
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by arbfp_blitter_blit(), context_generate_rt_mask_from_resource(), fb_copy_to_texture_direct(), fb_copy_to_texture_hwstretch(), ffp_blitter_blit(), glsl_blitter_blit(), texture2d_blt_fbo(), texture2d_load_fb_texture(), and texture2d_read_from_framebuffer().

◆ wined3d_texture_get_gl_sample_count()

static unsigned int wined3d_texture_get_gl_sample_count ( const struct wined3d_texture texture)
static

Definition at line 529 of file texture.c.

530 {
531  const struct wined3d_format *format = texture->resource.format;
532 
533  /* TODO: NVIDIA expose their Coverage Sample Anti-Aliasing (CSAA)
534  * feature through type == MULTISAMPLE_XX and quality != 0. This could
535  * be mapped to GL_NV_framebuffer_multisample_coverage.
536  *
537  * AMD have a similar feature called Enhanced Quality Anti-Aliasing
538  * (EQAA), but it does not have an equivalent OpenGL extension. */
539 
540  /* We advertise as many WINED3D_MULTISAMPLE_NON_MASKABLE quality
541  * levels as the count of advertised multisample types for the texture
542  * format. */
543  if (texture->resource.multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
544  {
545  unsigned int i, count = 0;
546 
547  for (i = 0; i < sizeof(format->multisample_types) * CHAR_BIT; ++i)
548  {
549  if (format->multisample_types & 1u << i)
550  {
551  if (texture->resource.multisample_quality == count++)
552  break;
553  }
554  }
555  return i + 1;
556  }
557 
558  return texture->resource.multisample_type;
559 }
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
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CHAR_BIT
Definition: urlcache.c:57
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
GLenum GLuint texture
Definition: glext.h:6295

Referenced by wined3d_texture_allocate_gl_immutable_storage(), and wined3d_texture_prepare_rb().

◆ wined3d_texture_get_level_count()

◆ wined3d_texture_get_lod()

DWORD CDECL wined3d_texture_get_lod ( const struct wined3d_texture texture)

Definition at line 1417 of file texture.c.

1418 {
1419  TRACE("texture %p, returning %u.\n", texture, texture->lod);
1420 
1421  return texture->lod;
1422 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295

Referenced by d3d8_texture_2d_GetLOD(), d3d8_texture_3d_GetLOD(), d3d8_texture_cube_GetLOD(), d3d9_texture_2d_GetLOD(), d3d9_texture_3d_GetLOD(), d3d9_texture_cube_GetLOD(), and ddraw_surface7_GetLOD().

◆ wined3d_texture_get_memory()

void wined3d_texture_get_memory ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_bo_address data,
DWORD  locations 
)

Definition at line 436 of file texture.c.

438 {
439  struct wined3d_texture_sub_resource *sub_resource;
440 
441  TRACE("texture %p, sub_resource_idx %u, data %p, locations %s.\n",
442  texture, sub_resource_idx, data, wined3d_debug_location(locations));
443 
444  sub_resource = &texture->sub_resources[sub_resource_idx];
446  {
447  data->addr = NULL;
448  data->buffer_object = sub_resource->buffer_object;
449  return;
450  }
452  {
453  data->addr = texture->user_memory;
454  data->buffer_object = 0;
455  return;
456  }
458  {
459  data->addr = texture->resource.heap_memory;
460  data->addr += sub_resource->offset;
461  data->buffer_object = 0;
462  return;
463  }
464 
465  ERR("Unexpected locations %s.\n", wined3d_debug_location(locations));
466  data->addr = NULL;
467  data->buffer_object = 0;
468 }
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6306
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_LOCATION_USER_MEMORY
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_LOCATION_SYSMEM
GLsizei const GLint * locations
Definition: glext.h:10542
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by surface_convert_format(), surface_cpu_blt(), surface_cpu_blt_colour_fill(), texture2d_download_data(), texture2d_load_texture(), texture2d_read_from_framebuffer(), texture_resource_sub_resource_map(), texture_resource_sub_resource_unmap(), wined3d_cs_exec_blt_sub_resource(), wined3d_texture_copy_sysmem_location(), wined3d_texture_create_dc(), wined3d_texture_destroy_dc(), and wined3d_texture_upload_from_texture().

◆ wined3d_texture_get_overlay_position()

HRESULT CDECL wined3d_texture_get_overlay_position ( const struct wined3d_texture texture,
unsigned int  sub_resource_idx,
LONG x,
LONG y 
)

Definition at line 3139 of file texture.c.

3141 {
3142  struct wined3d_overlay_info *overlay;
3143 
3144  TRACE("texture %p, sub_resource_idx %u, x %p, y %p.\n", texture, sub_resource_idx, x, y);
3145 
3146  if (!(texture->resource.usage & WINED3DUSAGE_OVERLAY)
3147  || sub_resource_idx >= texture->level_count * texture->layer_count)
3148  {
3149  WARN("Invalid sub-resource specified.\n");
3151  }
3152 
3153  overlay = &texture->overlay_info[sub_resource_idx];
3154  if (!overlay->dst_texture)
3155  {
3156  TRACE("Overlay not visible.\n");
3157  *x = 0;
3158  *y = 0;
3160  }
3161 
3162  *x = overlay->dst_rect.left;
3163  *y = overlay->dst_rect.top;
3164 
3165  TRACE("Returning position %d, %d.\n", *x, *y);
3166 
3167  return WINED3D_OK;
3168 }
#define WINED3DUSAGE_OVERLAY
Definition: wined3d.h:930
#define WARN(fmt,...)
Definition: debug.h:111
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37
#define WINEDDERR_OVERLAYNOTVISIBLE
Definition: wined3d.h:53
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define WINEDDERR_NOTAOVERLAYSURFACE
Definition: wined3d.h:49

Referenced by ddraw_surface7_GetOverlayPosition().

◆ wined3d_texture_get_parent()

void* CDECL wined3d_texture_get_parent ( const struct wined3d_texture texture)

◆ wined3d_texture_get_pitch()

void CDECL wined3d_texture_get_pitch ( const struct wined3d_texture texture,
unsigned int  level,
unsigned int row_pitch,
unsigned int slice_pitch 
)

Definition at line 1364 of file texture.c.

1366 {
1367  const struct wined3d_resource *resource = &texture->resource;
1370 
1371  if (texture->row_pitch)
1372  {
1373  *row_pitch = texture->row_pitch;
1374  *slice_pitch = texture->slice_pitch;
1375  return;
1376  }
1377 
1378  wined3d_format_calculate_pitch(resource->format, resource->device->surface_alignment,
1379  width, height, row_pitch, slice_pitch);
1380 }
GLint level
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
GLenum GLuint texture
Definition: glext.h:6295
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)
Definition: utils.c:3818
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546

Referenced by ddraw_surface_init(), surface_convert_format(), surface_cpu_blt(), surface_cpu_blt_colour_fill(), texture1d_load_location(), texture2d_download_data(), texture2d_load_texture(), texture2d_read_from_framebuffer(), texture3d_load_location(), texture3d_srgb_transfer(), texture_resource_sub_resource_map(), texture_resource_sub_resource_map_info(), wined3d_cs_exec_blt_sub_resource(), wined3d_texture_create_dc(), and wined3d_texture_upload_from_texture().

◆ wined3d_texture_get_resource()

◆ wined3d_texture_get_sub_resource()

static struct wined3d_texture_sub_resource* wined3d_texture_get_sub_resource ( struct wined3d_texture texture,
unsigned int  sub_resource_idx 
)
static

Definition at line 1849 of file texture.c.

1851 {
1852  UINT sub_count = texture->level_count * texture->layer_count;
1853 
1854  TRACE("texture %p, sub_resource_idx %u.\n", texture, sub_resource_idx);
1855 
1856  if (sub_resource_idx >= sub_count)
1857  {
1858  WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
1859  return NULL;
1860  }
1861 
1862  return &texture->sub_resources[sub_resource_idx];
1863 }
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
unsigned int UINT
Definition: ndis.h:50

Referenced by texture_resource_sub_resource_map(), texture_resource_sub_resource_map_info(), texture_resource_sub_resource_unmap(), wined3d_texture_get_dc(), and wined3d_texture_release_dc().

◆ wined3d_texture_get_sub_resource_desc()

HRESULT CDECL wined3d_texture_get_sub_resource_desc ( const struct wined3d_texture texture,
unsigned int  sub_resource_idx,
struct wined3d_sub_resource_desc desc 
)

Definition at line 3295 of file texture.c.

3297 {
3298  unsigned int sub_count = texture->level_count * texture->layer_count;
3299  const struct wined3d_resource *resource;
3300  unsigned int level_idx;
3301 
3302  TRACE("texture %p, sub_resource_idx %u, desc %p.\n", texture, sub_resource_idx, desc);
3303 
3304  if (sub_resource_idx >= sub_count)
3305  {
3306  WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
3307  return WINED3DERR_INVALIDCALL;
3308  }
3309 
3310  resource = &texture->resource;
3311  desc->format = resource->format->id;
3312  desc->multisample_type = resource->multisample_type;
3313  desc->multisample_quality = resource->multisample_quality;
3314  desc->usage = resource->usage;
3315  desc->access = resource->access;
3316 
3317  level_idx = sub_resource_idx % texture->level_count;
3318  desc->width = wined3d_texture_get_level_width(texture, level_idx);
3319  desc->height = wined3d_texture_get_level_height(texture, level_idx);
3320  desc->depth = wined3d_texture_get_level_depth(texture, level_idx);
3321  desc->size = texture->sub_resources[sub_resource_idx].size;
3322 
3323  return WINED3D_OK;
3324 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WARN(fmt,...)
Definition: debug.h:111
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
int resource
Definition: rdpsnd_sgi.c:44
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3D_OK
Definition: wined3d.h:37

Referenced by d3d8_device_CopyRects(), d3d8_device_SetRenderTarget(), d3d8_device_SetViewport(), d3d8_surface_GetDesc(), d3d8_texture_2d_GetLevelDesc(), d3d8_texture_3d_GetLevelDesc(), d3d8_texture_cube_GetLevelDesc(), d3d8_volume_GetDesc(), d3d9_device_ColorFill(), d3d9_device_GetRenderTargetData(), d3d9_device_StretchRect(), d3d9_device_UpdateSurface(), d3d9_surface_GetDesc(), d3d9_texture_2d_GetLevelDesc(), d3d9_texture_3d_GetLevelDesc(), d3d9_texture_acquire_shader_resource_view(), d3d9_texture_cube_GetLevelDesc(), d3d9_volume_GetDesc(), d3d_device7_SetViewport(), d3d_viewport_SetViewport(), d3d_viewport_SetViewport2(), ddraw_surface7_Restore(), and ddraw_surface_create().

◆ wined3d_texture_get_sub_resource_parent()

void* CDECL wined3d_texture_get_sub_resource_parent ( struct wined3d_texture texture,
unsigned int  sub_resource_idx 
)

Definition at line 3264 of file texture.c.

3265 {
3266  unsigned int sub_count = texture->level_count * texture->layer_count;
3267 
3268  TRACE("texture %p, sub_resource_idx %u.\n", texture, sub_resource_idx);
3269 
3270  if (sub_resource_idx >= sub_count)
3271  {
3272  WARN("sub_resource_idx %u >= sub_count %u.\n", sub_resource_idx, sub_count);
3273  return NULL;
3274  }
3275 
3276  return texture->sub_resources[sub_resource_idx].parent;
3277 }
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295

Referenced by d3d8_device_create_surface(), d3d8_device_GetBackBuffer(), d3d8_swapchain_GetBackBuffer(), d3d8_texture_2d_GetSurfaceLevel(), d3d8_texture_2d_LockRect(), d3d8_texture_2d_UnlockRect(), d3d8_texture_3d_GetVolumeLevel(), d3d8_texture_3d_LockBox(), d3d8_texture_3d_UnlockBox(), d3d8_texture_cube_GetCubeMapSurface(), d3d8_texture_cube_LockRect(), d3d8_texture_cube_UnlockRect(), d3d9_device_create_surface(), d3d9_swapchain_GetBackBuffer(), d3d9_texture_2d_GetSurfaceLevel(), d3d9_texture_2d_LockRect(), d3d9_texture_2d_UnlockRect(), d3d9_texture_3d_GetVolumeLevel(), d3d9_texture_3d_LockBox(), d3d9_texture_3d_UnlockBox(), d3d9_texture_cube_GetCubeMapSurface(), d3d9_texture_cube_LockRect(), d3d9_texture_cube_UnlockRect(), ddraw_surface_create(), device_parent_create_swapchain_texture(), and reset_enum_callback().

◆ wined3d_texture_incref()

ULONG CDECL wined3d_texture_incref ( struct wined3d_texture texture)

Definition at line 1190 of file texture.c.

1191 {
1192  ULONG refcount;
1193 
1194  TRACE("texture %p, swapchain %p.\n", texture, texture->swapchain);
1195 
1196  if (texture->swapchain)
1197  return wined3d_swapchain_incref(texture->swapchain);
1198 
1199  refcount = InterlockedIncrement(&texture->resource.ref);
1200  TRACE("%p increasing refcount to %u.\n", texture, refcount);
1201 
1202  return refcount;
1203 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define InterlockedIncrement
Definition: armddk.h:53
ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:104
unsigned int ULONG
Definition: retypes.h:1

Referenced by d3d8_surface_AddRef(), d3d8_texture_2d_AddRef(), d3d8_texture_3d_AddRef(), d3d8_texture_cube_AddRef(), d3d9_surface_AddRef(), d3d9_texture_2d_AddRef(), d3d9_texture_3d_AddRef(), d3d9_texture_cube_AddRef(), ddraw_surface_add_iface(), ddraw_surface_init(), texture_resource_incref(), wined3d_device_set_texture(), and wined3d_stateblock_capture().

◆ wined3d_texture_init()

static HRESULT wined3d_texture_init ( struct wined3d_texture texture,
const struct wined3d_resource_desc desc,
unsigned int  layer_count,
unsigned int  level_count,
DWORD  flags,
struct wined3d_device device,
void parent,
const struct wined3d_parent_ops parent_ops,
const struct wined3d_texture_ops texture_ops 
)
static

Definition at line 2574 of file texture.c.

2577 {
2578  struct wined3d_device_parent *device_parent = device->device_parent;
2579  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
2580  unsigned int sub_count, i, j, size, offset = 0;
2581  unsigned int pow2_width, pow2_height;
2582  const struct wined3d_format *format;
2583  HRESULT hr;
2584 
2585  TRACE("texture %p, resource_type %s, format %s, multisample_type %#x, multisample_quality %#x, "
2586  "usage %s, access %s, width %u, height %u, depth %u, layer_count %u, level_count %u, "
2587  "flags %#x, device %p, parent %p, parent_ops %p, texture_ops %p.\n",
2588  texture, debug_d3dresourcetype(desc->resource_type), debug_d3dformat(desc->format),
2589  desc->multisample_type, desc->multisample_quality, debug_d3dusage(desc->usage),
2590  wined3d_debug_resource_access(desc->access), desc->width, desc->height, desc->depth,
2591  layer_count, level_count, flags, device, parent, parent_ops, texture_ops);
2592 
2593  if (!desc->width || !desc->height || !desc->depth)
2594  return WINED3DERR_INVALIDCALL;
2595 
2596  if (desc->resource_type == WINED3D_RTYPE_TEXTURE_3D)
2597  {
2598  if (layer_count != 1)
2599  {
2600  ERR("Invalid layer count for volume texture.\n");
2601  return E_INVALIDARG;
2602  }
2603 
2604  if (!gl_info->supported[EXT_TEXTURE3D])
2605  {
2606  WARN("OpenGL implementation does not support 3D textures.\n");
2607  return WINED3DERR_INVALIDCALL;
2608  }
2609  }
2610 
2611  if (!(desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) && layer_count > 1
2612  && !gl_info->supported[EXT_TEXTURE_ARRAY])
2613  {
2614  WARN("OpenGL implementation does not support array textures.\n");
2615  return WINED3DERR_INVALIDCALL;
2616  }
2617 
2618  /* TODO: It should only be possible to create textures for formats
2619  * that are reported as supported. */
2620  if (WINED3DFMT_UNKNOWN >= desc->format)
2621  {
2622  WARN("Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n");
2623  return WINED3DERR_INVALIDCALL;
2624  }
2625 
2627  || desc->usage & WINED3DUSAGE_SCRATCH))
2628  {
2629  WARN("Attempted to create a dynamic texture with access %s and usage %s.\n",
2631  return WINED3DERR_INVALIDCALL;
2632  }
2633 
2636  WARN("Creating a mappable texture that doesn't specify dynamic usage.\n");
2638  FIXME("Trying to create a CPU accessible render target.\n");
2639 
2640  pow2_width = desc->width;
2641  pow2_height = desc->height;
2642  if (((desc->width & (desc->width - 1)) || (desc->height & (desc->height - 1)) || (desc->depth & (desc->depth - 1)))
2644  {
2645  /* level_count == 0 returns an error as well. */
2646  if (level_count != 1 || layer_count != 1 || desc->resource_type == WINED3D_RTYPE_TEXTURE_3D)
2647  {
2648  if (!(desc->usage & WINED3DUSAGE_SCRATCH))
2649  {
2650  WARN("Attempted to create a mipmapped/cube/array/volume NPOT "
2651  "texture without unconditional NPOT support.\n");
2652  return WINED3DERR_INVALIDCALL;
2653  }
2654 
2655  WARN("Creating a scratch mipmapped/cube/array NPOT texture despite lack of HW support.\n");
2656  }
2658 
2659  if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE]
2661  {
2662  const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format, desc->usage);
2663 
2664  /* TODO: Add support for non-power-of-two compressed textures. */
2667  {
2668  FIXME("Compressed or height scaled non-power-of-two (%ux%u) textures are not supported.\n",
2669  desc->width, desc->height);
2670  return WINED3DERR_NOTAVAILABLE;
2671  }
2672 
2673  /* Find the nearest pow2 match. */
2674  pow2_width = pow2_height = 1;
2675  while (pow2_width < desc->width)
2676  pow2_width <<= 1;
2677  while (pow2_height < desc->height)
2678  pow2_height <<= 1;
2680  }
2681  }
2682  texture->pow2_width = pow2_width;
2683  texture->pow2_height = pow2_height;
2684 
2685  if ((pow2_width > gl_info->limits.texture_size || pow2_height > gl_info->limits.texture_size)
2686  && (desc->usage & WINED3DUSAGE_TEXTURE))
2687  {
2688  /* One of four options:
2689  * 1: Do the same as we do with NPOT and scale the texture. (Any
2690  * texture ops would require the texture to be scaled which is
2691  * potentially slow.)
2692  * 2: Set the texture to the maximum size (bad idea).
2693  * 3: WARN and return WINED3DERR_NOTAVAILABLE.
2694  * 4: Create the surface, but allow it to be used only for DirectDraw
2695  * Blts. Some apps (e.g. Swat 3) create textures with a height of
2696  * 16 and a width > 3000 and blt 16x16 letter areas from them to
2697  * the render target. */
2698  if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
2699  {
2700  WARN("Dimensions (%ux%u) exceed the maximum texture size.\n", pow2_width, pow2_height);
2701  return WINED3DERR_NOTAVAILABLE;
2702  }
2703 
2704  /* We should never use this surface in combination with OpenGL. */
2705  TRACE("Creating an oversized (%ux%u) surface.\n", pow2_width, pow2_height);
2706  }
2707 
2708  format = wined3d_get_format(&device->adapter->gl_info, desc->format, desc->usage);
2709  for (i = 0; i < layer_count; ++i)
2710  {
2711  for (j = 0; j < level_count; ++j)
2712  {
2713  unsigned int idx = i * level_count + j;
2714 
2715  size = wined3d_format_calculate_size(format, device->surface_alignment,
2716  max(1, desc->width >> j), max(1, desc->height >> j), max(1, desc->depth >> j));
2717  texture->sub_resources[idx].offset = offset;
2718  texture->sub_resources[idx].size = size;
2719  offset += size;
2720  }
2721  offset = (offset + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1);
2722  }
2723 
2724  if (!offset)
2725  return WINED3DERR_INVALIDCALL;
2726 
2727  if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, format,
2728  desc->multisample_type, desc->multisample_quality, desc->usage, desc->access,
2729  desc->width, desc->height, desc->depth, offset, parent, parent_ops, &