ReactOS  0.4.14-dev-57-g333b8f1
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.

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)
 
GLenum wined3d_texture_get_gl_buffer (const struct wined3d_texture *texture)
 
static DWORD wined3d_resource_access_from_location (DWORD location)
 
static BOOL is_power_of_two (UINT x)
 
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 HRESULT wined3d_texture_init (struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
 
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_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)
 
static void texture2d_create_dc (void *object)
 
static void texture2d_destroy_dc (void *object)
 
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, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
 
static void texture1d_upload_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
 
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 void texture1d_srgb_transfer (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, BOOL dest_is_srgb)
 
static BOOL texture1d_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
static void texture1d_prepare_texture (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
static void texture1d_cleanup_sub_resources (struct wined3d_texture *texture)
 
static void texture2d_upload_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
 
static BOOL texture2d_load_location (struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
 
static void texture2d_prepare_texture (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
static void texture2d_cleanup_sub_resources (struct wined3d_texture *texture)
 
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 HRESULT texture1d_init (struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static HRESULT 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)
 
static void texture3d_upload_data (struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
 
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)
 
static void texture3d_prepare_texture (struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
 
static void texture3d_cleanup_sub_resources (struct wined3d_texture *texture)
 
static HRESULT volumetexture_init (struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
 
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)
 

Variables

static const struct wined3d_texture_ops texture1d_ops
 
static const struct wined3d_texture_ops texture2d_ops
 
static const struct wined3d_resource_ops texture_resource_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 1059 of file texture.c.

1060 {
1063 }
DWORD color_space_low_value
Definition: wined3d.h:1980
DWORD color_space_high_value
Definition: wined3d.h:1982

Referenced by wined3d_texture_load().

◆ 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 476 of file texture.c.

478 {
480  gl_info->gl_ops.gl.p_glDeleteTextures(1, &tex->name);
481  tex->name = 0;
482 }
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:1104

Referenced by wined3d_texture_unload_gl_texture().

◆ is_power_of_two()

static BOOL is_power_of_two ( UINT  x)
static

Definition at line 104 of file texture.c.

105 {
106  return (x != 0) && !(x & (x - 1));
107 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by texture1d_init(), volumetexture_init(), and wined3d_texture_update_desc().

◆ texture1d_cleanup_sub_resources()

static void texture1d_cleanup_sub_resources ( struct wined3d_texture texture)
static

Definition at line 2072 of file texture.c.

2073 {
2074 }

◆ 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 1785 of file texture.c.

1787 {
1788  struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface;
1789  const struct wined3d_format *format = texture->resource.format;
1790  const struct wined3d_gl_info *gl_info = context->gl_info;
1791  struct wined3d_texture_sub_resource *sub_resource;
1792  BYTE *temporary_mem = NULL;
1793  void *mem;
1794  GLenum target;
1795 
1796  sub_resource = &texture->sub_resources[sub_resource_idx];
1797 
1798  if (format->conv_byte_count)
1799  {
1800  FIXME("Attempting to download a converted 1d texture, format %s.\n",
1801  debug_d3dformat(format->id));
1802  return;
1803  }
1804 
1806  if (target == GL_TEXTURE_1D_ARRAY)
1807  {
1808  WARN_(d3d_perf)("Downloading all miplevel layers to get the surface data for a single sub-resource.\n");
1809 
1810  if (!(temporary_mem = heap_calloc(texture->layer_count, sub_resource->size)))
1811  {
1812  ERR("Out of memory.\n");
1813  return;
1814  }
1815 
1816  mem = temporary_mem;
1817  }
1818  else if (data->buffer_object)
1819  {
1820  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
1821  checkGLcall("glBindBuffer");
1822  mem = data->addr;
1823  }
1824  else
1825  mem = data->addr;
1826 
1827  gl_info->gl_ops.gl.p_glGetTexImage(target, sub_resource_idx,
1828  format->glFormat, format->glType, mem);
1829  checkGLcall("glGetTexImage");
1830 
1831  if (temporary_mem)
1832  {
1833  void *src_data = temporary_mem + surface->texture_layer * sub_resource->size;
1834  if (data->buffer_object)
1835  {
1836  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
1837  checkGLcall("glBindBuffer");
1838  GL_EXTCALL(glBufferSubData(GL_PIXEL_PACK_BUFFER, 0, sub_resource->size, src_data));
1839  checkGLcall("glBufferSubData");
1840  }
1841  else
1842  {
1843  memcpy(data->addr, src_data, sub_resource->size);
1844  }
1845  }
1846 
1847  if (data->buffer_object)
1848  {
1849  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
1850  checkGLcall("glBindBuffer");
1851  }
1852 
1853  HeapFree(GetProcessHeap(), 0, temporary_mem);
1854 }
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
struct opengl_funcs gl_ops
Definition: http.c:6587
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
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
#define GetProcessHeap()
Definition: compat.h:395
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int texture_layer
#define checkGLcall(A)
#define GL_PIXEL_PACK_BUFFER
Definition: glext.h:476
Definition: mem.c:156
GLenum target
Definition: glext.h:7315
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3973
#define WARN_(ch,...)
Definition: debug.h:157
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by texture1d_load_location(), and texture1d_srgb_transfer().

◆ texture1d_init()

static HRESULT texture1d_init ( struct wined3d_texture texture,
const struct wined3d_resource_desc desc,
UINT  layer_count,
UINT  level_count,
struct wined3d_device device,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 2518 of file texture.c.

2521 {
2522  struct wined3d_device_parent *device_parent = device->device_parent;
2523  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
2524  struct wined3d_surface *surfaces;
2525  unsigned int i, j;
2526  HRESULT hr;
2527 
2528  if (layer_count > 1 && !gl_info->supported[EXT_TEXTURE_ARRAY])
2529  {
2530  WARN("OpenGL implementation does not support array textures.\n");
2531  return WINED3DERR_INVALIDCALL;
2532  }
2533 
2534  /* TODO: It should only be possible to create textures for formats
2535  * that are reported as supported. */
2536  if (WINED3DFMT_UNKNOWN >= desc->format)
2537  {
2538  WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
2539  return WINED3DERR_INVALIDCALL;
2540  }
2541 
2542  if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
2543  {
2544  WARN("1d textures can not be used for cube mapping, returning D3DERR_INVALIDCALL.\n");
2545  return WINED3DERR_INVALIDCALL;
2546  }
2547 
2549  || (desc->usage & WINED3DUSAGE_SCRATCH))
2550  {
2551  WARN("Attempted to create a DYNAMIC texture in pool %s.\n", wined3d_debug_resource_access(desc->access));
2552  return WINED3DERR_INVALIDCALL;
2553  }
2554 
2555  if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] && !is_power_of_two(desc->width))
2556  {
2557  if (desc->usage & WINED3DUSAGE_SCRATCH)
2558  {
2559  WARN("Creating a scratch NPOT 1d texture despite lack of HW support.\n");
2560  }
2561  else
2562  {
2563  WARN("Attempted to create a NPOT 1d texture (%u, %u, %u) without GL support.\n",
2564  desc->width, desc->height, desc->depth);
2565  return WINED3DERR_INVALIDCALL;
2566  }
2567  }
2568 
2569  if (desc->usage & WINED3DUSAGE_QUERY_GENMIPMAP)
2570  {
2571  if (level_count != 1)
2572  {
2573  WARN("WINED3DUSAGE_QUERY_GENMIPMAP is set, and level count != 1, returning WINED3DERR_INVALIDCALL.\n");
2574  return WINED3DERR_INVALIDCALL;
2575  }
2576  }
2577 
2578  if (FAILED(hr = wined3d_texture_init(texture, &texture1d_ops, layer_count, level_count, desc,
2579  0, device, parent, parent_ops, &texture_resource_ops)))
2580  {
2581  WARN("Failed to initialize texture, returning %#x.\n", hr);
2582  return hr;
2583  }
2584 
2585  texture->pow2_matrix[0] = 1.0f;
2586  texture->pow2_matrix[5] = 1.0f;
2587  texture->pow2_matrix[10] = 1.0f;
2588  texture->pow2_matrix[15] = 1.0f;
2589  texture->target = (layer_count > 1) ? GL_TEXTURE_1D_ARRAY : GL_TEXTURE_1D;
2590 
2591  if (wined3d_texture_use_pbo(texture, gl_info))
2592  {
2594  texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
2595  }
2596 
2597  if (level_count > ~(SIZE_T)0 / layer_count
2598  || !(surfaces = heap_calloc(level_count * layer_count, sizeof(*surfaces))))
2599  {
2601  return E_OUTOFMEMORY;
2602  }
2603 
2604  /* Generate all the surfaces. */
2605  for (i = 0; i < texture->level_count; ++i)
2606  {
2607  for (j = 0; j < texture->layer_count; ++j)
2608  {
2609  struct wined3d_texture_sub_resource *sub_resource;
2610  unsigned int idx = j * texture->level_count + i;
2611  struct wined3d_surface *surface;
2612 
2613  surface = &surfaces[idx];
2614  surface->container = texture;
2615  surface->texture_level = i;
2616  surface->texture_layer = j;
2617  list_init(&surface->renderbuffers);
2618 
2619  sub_resource = &texture->sub_resources[idx];
2620  sub_resource->locations = WINED3D_LOCATION_DISCARDED;
2621  sub_resource->u.surface = surface;
2622 
2623  if (FAILED(hr = device_parent->ops->surface_created(device_parent,
2624  texture, idx, &sub_resource->parent, &sub_resource->parent_ops)))
2625  {
2626  WARN("Failed to create texture1d parent, hr %#x.\n", hr);
2627  sub_resource->parent = NULL;
2629  return hr;
2630  }
2631 
2632  TRACE("parent %p, parent_ops %p.\n", parent, parent_ops);
2633 
2634  TRACE("Created 1d texture surface level %u, layer %u @ %p.\n", i, j, surface);
2635  }
2636  }
2637 
2638  return WINED3D_OK;
2639 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
HRESULT hr
Definition: shlfolder.c:183
static const struct wined3d_texture_ops texture1d_ops
Definition: texture.c:2076
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:907
#define WARN(fmt,...)
Definition: debug.h:111
#define WINED3D_LOCATION_BUFFER
const GLvdpauSurfaceNV * surfaces
Definition: glext.h:11586
unsigned int texture_level
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
Definition: texture.c:1009
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
#define GL_TEXTURE_1D
Definition: gl.h:644
Definition: devices.h:37
static BOOL wined3d_resource_access_is_managed(unsigned int access)
BOOL supported[WINED3D_GL_EXT_COUNT]
unsigned int idx
Definition: utils.c:41
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define WINED3DUSAGE_LEGACY_CUBEMAP
Definition: wined3d.h:917
#define WINED3DUSAGE_QUERY_GENMIPMAP
Definition: wined3d.h:923
static const struct wined3d_resource_ops texture_resource_ops
Definition: texture.c:2507
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2897
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
static BOOL is_power_of_two(UINT x)
Definition: texture.c:104
const struct wined3d_device_parent_ops * ops
Definition: wined3d.h:2133
unsigned int texture_layer
ULONG_PTR SIZE_T
Definition: typedefs.h:78
struct list renderbuffers
static BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:33
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:915
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define WINED3D_LOCATION_DISCARDED
struct wined3d_texture * container
const char * wined3d_debug_resource_access(DWORD access)
Definition: utils.c:4193
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
Definition: texture.c:323
void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
Definition: resource.c:504

Referenced by wined3d_texture_create().

◆ 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 1880 of file texture.c.

1882 {
1883  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
1885  unsigned int row_pitch, slice_pitch;
1886 
1887  TRACE("texture %p, sub_resource_idx %u, context %p, location %s.\n",
1888  texture, sub_resource_idx, context, wined3d_debug_location(location));
1889 
1890  TRACE("Current resource location %s.\n", wined3d_debug_location(sub_resource->locations));
1891 
1892  if ((sub_resource->locations & location) == location)
1893  {
1894  TRACE("Location(s) already up to date.\n");
1895  return TRUE;
1896  }
1897 
1898  if ((texture->resource.access & required_access) != required_access)
1899  {
1900  ERR("Operation requires %#x access, but 1d texture only has %#x.\n",
1901  required_access, texture->resource.access);
1902  return FALSE;
1903  }
1904 
1905  if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
1906  return FALSE;
1907 
1908  if (sub_resource->locations & WINED3D_LOCATION_DISCARDED)
1909  {
1910  TRACE("1d texture previously discarded, nothing to do.\n");
1913  goto done;
1914  }
1915 
1916  switch (location)
1917  {
1920  if (sub_resource->locations & WINED3D_LOCATION_SYSMEM)
1921  {
1922  struct wined3d_const_bo_address data = {0, texture->resource.heap_memory};
1923  data.addr += sub_resource->offset;
1925  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
1926  texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
1927  }
1928  else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
1929  {
1930 #if !defined(STAGING_CSMT)
1931  struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
1932 #else /* STAGING_CSMT */
1933  struct wined3d_const_bo_address data = {sub_resource->buffer->name, NULL};
1934 #endif /* STAGING_CSMT */
1936  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
1937  texture1d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
1938  }
1939  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
1940  {
1941  texture1d_srgb_transfer(texture, sub_resource_idx, context, TRUE);
1942  }
1943  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_SRGB)
1944  {
1945  texture1d_srgb_transfer(texture, sub_resource_idx, context, FALSE);
1946  }
1947  else
1948  {
1949  FIXME("Implement 1d texture loading from %s.\n", wined3d_debug_location(sub_resource->locations));
1950  return FALSE;
1951  }
1952  break;
1953 
1955  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
1956  {
1957  struct wined3d_bo_address data = {0, texture->resource.heap_memory};
1958 
1959  data.addr += sub_resource->offset;
1960  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
1962  else
1964 
1965  texture1d_download_data(texture, sub_resource_idx, context, &data);
1966  ++texture->download_count;
1967  }
1968  else
1969  {
1970  FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n",
1971  wined3d_debug_location(sub_resource->locations));
1972  return FALSE;
1973  }
1974  break;
1975 
1977  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
1978  {
1979 #if !defined(STAGING_CSMT)
1980  struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
1981 #else /* STAGING_CSMT */
1982  struct wined3d_bo_address data = {sub_resource->buffer->name, NULL};
1983 #endif /* STAGING_CSMT */
1984 
1985  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
1987  else
1989 
1990  texture1d_download_data(texture, sub_resource_idx, context, &data);
1991  }
1992  else
1993  {
1994  FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n",
1995  wined3d_debug_location(sub_resource->locations));
1996  return FALSE;
1997  }
1998  break;
1999 
2000  default:
2001  FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location),
2002  wined3d_debug_location(sub_resource->locations));
2003  return FALSE;
2004  }
2005 
2006 done:
2008 
2009  return TRUE;
2010 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6389
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1605
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_LOCATION_SYSMEM
#define ERR(fmt,...)
Definition: debug.h:109
static void texture1d_srgb_transfer(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, BOOL dest_is_srgb)
Definition: texture.c:1857
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
#define WINED3D_LOCATION_TEXTURE_RGB
static DWORD wined3d_resource_access_from_location(DWORD location)
Definition: texture.c:79
static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: texture.c:1708
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
#define WINED3D_LOCATION_DISCARDED
#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:1168
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:1785

◆ texture1d_prepare_texture()

static void texture1d_prepare_texture ( struct wined3d_texture texture,
struct wined3d_context context,
BOOL  srgb 
)
static

Definition at line 2012 of file texture.c.

2013 {
2014  const struct wined3d_format *format = texture->resource.format;
2015  unsigned int sub_count = texture->level_count * texture->layer_count;
2016  const struct wined3d_gl_info *gl_info = context->gl_info;
2017  unsigned int width;
2018  GLenum internal;
2019 
2021 
2022  if (srgb)
2023  internal = format->glGammaInternal;
2024  else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
2025  && wined3d_resource_is_offscreen(&texture->resource))
2026  internal = format->rtInternal;
2027  else
2028  internal = format->glInternal;
2029 
2031  {
2033 
2034  if (texture->target == GL_TEXTURE_1D_ARRAY)
2035  {
2036  GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count, internal, width, texture->layer_count));
2037  checkGLcall("glTexStorage2D");
2038  }
2039  else
2040  {
2041  GL_EXTCALL(glTexStorage1D(texture->target, texture->level_count, internal, width));
2042  checkGLcall("glTexStorage1D");
2043  }
2044  }
2045  else
2046  {
2047  unsigned int i;
2048 
2049  for (i = 0; i < sub_count; ++i)
2050  {
2051  GLenum target;
2052  struct wined3d_surface *surface = texture->sub_resources[i].u.surface;
2055 
2056  if (texture->target == GL_TEXTURE_1D_ARRAY)
2057  {
2058  gl_info->gl_ops.gl.p_glTexImage2D(target, surface->texture_level,
2059  internal, width, texture->layer_count, 0, format->glFormat, format->glType, NULL);
2060  checkGLcall("glTexImage2D");
2061  }
2062  else
2063  {
2064  gl_info->gl_ops.gl.p_glTexImage1D(target, surface->texture_level,
2065  internal, width, 0, format->glFormat, format->glType, NULL);
2066  checkGLcall("glTexImage1D");
2067  }
2068  }
2069  }
2070 }
static GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture, unsigned int sub_resource_idx)
GLint GLint GLsizei width
Definition: gl.h:1546
struct opengl_funcs gl_ops
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
unsigned int texture_level
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static BOOL wined3d_texture_use_immutable_storage(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:42
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
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
unsigned int GLenum
Definition: gl.h:150
#define checkGLcall(A)
GLenum target
Definition: glext.h:7315
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868

◆ texture1d_srgb_transfer()

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

Definition at line 1857 of file texture.c.

1859 {
1860  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
1861  unsigned int row_pitch, slice_pitch;
1862  struct wined3d_bo_address data;
1863 
1864  WARN_(d3d_perf)("Performing slow rgb/srgb 1d texture transfer.\n");
1865  data.buffer_object = 0;
1866  if (!(data.addr = HeapAlloc(GetProcessHeap(), 0, sub_resource->size)))
1867  return;
1868 
1869  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
1871  texture1d_download_data(texture, sub_resource_idx, context, &data);
1873  texture1d_upload_data(texture, sub_resource_idx, context, NULL,
1874  wined3d_const_bo_address(&data), row_pitch, slice_pitch);
1875 
1876  HeapFree(GetProcessHeap(), 0, data.addr);
1877 }
Definition: http.c:6587
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static struct wined3d_const_bo_address * wined3d_const_bo_address(struct wined3d_bo_address *data)
static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: texture.c:1708
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
#define WARN_(ch,...)
Definition: debug.h:157
#define HeapFree(x, y, z)
Definition: compat.h:394
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1168
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:1785

Referenced by texture1d_load_location().

◆ texture1d_upload_data()

static void texture1d_upload_data ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_context context,
const struct wined3d_box box,
const struct wined3d_const_bo_address data,
unsigned int  row_pitch,
unsigned int  slice_pitch 
)
static

Definition at line 1708 of file texture.c.

1711 {
1712  struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface;
1713  const struct wined3d_format *format = texture->resource.format;
1714  unsigned int level = sub_resource_idx % texture->level_count;
1715  const struct wined3d_gl_info *gl_info = context->gl_info;
1716  const void *mem = data->addr;
1717  void *converted_mem = NULL;
1718  unsigned int width, x, update_w;
1719  GLenum target;
1720 
1721  TRACE("texture %p, sub_resource_idx %u, context %p, box %p, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n",
1722  texture, sub_resource_idx, context, box, data->buffer_object, data->addr, row_pitch, slice_pitch);
1723 
1725 
1726  if (!box)
1727  {
1728  x = 0;
1729  update_w = width;
1730  }
1731  else
1732  {
1733  x = box->left;
1734  update_w = box->right - box->left;
1735  }
1736 
1737  if (format->upload)
1738  {
1739  unsigned int dst_row_pitch;
1740 
1741  if (data->buffer_object)
1742  ERR("Loading a converted texture from a PBO.\n");
1743  if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
1744  ERR("Converting a block-based format.\n");
1745 
1746  dst_row_pitch = update_w * format->conv_byte_count;
1747 
1748  converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_row_pitch);
1749  format->upload(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1);
1750  mem = converted_mem;
1751  }
1752 
1753  if (data->buffer_object)
1754  {
1755  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object));
1756  checkGLcall("glBindBuffer");
1757  }
1758 
1760  if (target == GL_TEXTURE_1D_ARRAY)
1761  {
1762  gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, row_pitch / format->byte_count);
1763 
1764  gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, x, surface->texture_layer, update_w, 1, format->glFormat, format->glType, mem);
1765  checkGLcall("glTexSubImage2D");
1766 
1767  gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
1768  }
1769  else
1770  {
1771  gl_info->gl_ops.gl.p_glTexSubImage1D(target, level, x, update_w, format->glFormat, format->glType, mem);
1772  checkGLcall("glTexSubImage1D");
1773  }
1774 
1775  if (data->buffer_object)
1776  {
1777  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
1778  checkGLcall("glBindBuffer");
1779  }
1780 
1781  HeapFree(GetProcessHeap(), 0, converted_mem);
1782 }
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
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WINED3DFMT_FLAG_BLOCKS
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GL_UNPACK_ROW_LENGTH
Definition: gl.h:634
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
unsigned int GLenum
Definition: gl.h:150
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int texture_layer
#define checkGLcall(A)
Definition: mem.c:156
GLenum target
Definition: glext.h:7315
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: palette.c:467

Referenced by texture1d_load_location(), and texture1d_srgb_transfer().

◆ texture2d_cleanup_sub_resources()

static void texture2d_cleanup_sub_resources ( struct wined3d_texture texture)
static

Definition at line 2161 of file texture.c.

2162 {
2163  unsigned int sub_count = texture->level_count * texture->layer_count;
2164  struct wined3d_device *device = texture->resource.device;
2165  struct wined3d_texture_sub_resource *sub_resource;
2166  struct wined3d_renderbuffer_entry *entry, *entry2;
2167  const struct wined3d_gl_info *gl_info = NULL;
2168  struct wined3d_context *context = NULL;
2169  struct wined3d_surface *surface;
2170  unsigned int i;
2171 
2172  for (i = 0; i < sub_count; ++i)
2173  {
2174  sub_resource = &texture->sub_resources[i];
2175  if (!(surface = sub_resource->u.surface))
2176  continue;
2177 
2178  TRACE("surface %p.\n", surface);
2179 
2180  if (!context && !list_empty(&surface->renderbuffers))
2181  {
2183  gl_info = context->gl_info;
2184  }
2185 
2187  {
2188  TRACE("Deleting renderbuffer %u.\n", entry->id);
2190  gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
2191  heap_free(entry);
2192  }
2193 
2194  if (surface->dc)
2195  texture2d_destroy_dc(surface);
2196  }
2197  if (context)
2199  heap_free(texture->sub_resources[0].u.surface);
2200 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
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
static void texture2d_destroy_dc(void *object)
Definition: texture.c:1316
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#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:4242
__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
struct list renderbuffers
struct wined3d_fbo_ops fbo_ops
void context_gl_resource_released(struct wined3d_device *device, GLuint name, BOOL rb_namespace)
Definition: context.c:1104
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ texture2d_create_dc()

static void texture2d_create_dc ( void object)
static

Definition at line 1255 of file texture.c.

1256 {
1257  struct wined3d_surface *surface = object;
1258  struct wined3d_context *context = NULL;
1259  const struct wined3d_format *format;
1260  unsigned int row_pitch, slice_pitch;
1261  struct wined3d_texture *texture;
1262  struct wined3d_bo_address data;
1264  unsigned int sub_resource_idx;
1265  struct wined3d_device *device;
1266  NTSTATUS status;
1267 
1268  TRACE("surface %p.\n", surface);
1269 
1270  texture = surface->container;
1271  sub_resource_idx = surface_get_sub_resource_idx(surface);
1272  device = texture->resource.device;
1273 
1274  format = texture->resource.format;
1275  if (!format->ddi_format)
1276  {
1277  WARN("Cannot create a DC for format %s.\n", debug_d3dformat(format->id));
1278  return;
1279  }
1280 
1281  if (device->d3d_initialized)
1283 
1284  wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding);
1285  wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding);
1286  wined3d_texture_get_pitch(texture, surface->texture_level, &row_pitch, &slice_pitch);
1287  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
1289  texture->sub_resources[sub_resource_idx].size,
1291 
1292  if (context)
1294 
1295  desc.Format = format->ddi_format;
1298  desc.Pitch = row_pitch;
1299  desc.hDeviceDc = CreateCompatibleDC(NULL);
1300  desc.pColorTable = NULL;
1301 
1303  DeleteDC(desc.hDeviceDc);
1304  if (status)
1305  {
1306  WARN("Failed to create DC, status %#x.\n", status);
1307  return;
1308  }
1309 
1310  surface->dc = desc.hDc;
1311  surface->bitmap = desc.hBitmap;
1312 
1313  TRACE("Created DC %p, bitmap %p for surface %p.\n", surface->dc, surface->bitmap, surface);
1314 }
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)
unsigned int texture_level
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
Definition: devices.h:37
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:285
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_MAP_READ
Definition: wined3d.h:939
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:938
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
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:159
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2802
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3973
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:1168
Definition: ps.c:97

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

◆ texture2d_destroy_dc()

static void texture2d_destroy_dc ( void object)
static

Definition at line 1316 of file texture.c.

1317 {
1318  struct wined3d_surface *surface = object;
1319  D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
1320  struct wined3d_context *context = NULL;
1321  struct wined3d_texture *texture;
1322  struct wined3d_bo_address data;
1323  unsigned int sub_resource_idx;
1324  struct wined3d_device *device;
1325  NTSTATUS status;
1326 
1327  texture = surface->container;
1328  sub_resource_idx = surface_get_sub_resource_idx(surface);
1329  device = texture->resource.device;
1330 
1331  if (!surface->dc)
1332  {
1333  ERR("Surface %p has no DC.\n", surface);
1334  return;
1335  }
1336 
1337  TRACE("dc %p, bitmap %p.\n", surface->dc, surface->bitmap);
1338 
1339  destroy_desc.hDc = surface->dc;
1340  destroy_desc.hBitmap = surface->bitmap;
1341  if ((status = D3DKMTDestroyDCFromMemory(&destroy_desc)))
1342  ERR("Failed to destroy dc, status %#x.\n", status);
1343  surface->dc = NULL;
1344  surface->bitmap = NULL;
1345 
1346  if (device->d3d_initialized)
1348 
1349  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
1351 
1352  if (context)
1354 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2831
Definition: http.c:6587
LONG NTSTATUS
Definition: precomp.h:26
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:285
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#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:4242
DWORD APIENTRY D3DKMTDestroyDCFromMemory(_In_ CONST D3DKMT_DESTROYDCFROMMEMORY *)
struct wined3d_texture * container
static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
static SERVICE_STATUS status
Definition: service.c:31
void * object
Definition: jmemsys.h:48
Definition: ps.c:97

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

◆ 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 2113 of file texture.c.

2115 {
2116  return surface_load_location(texture->sub_resources[sub_resource_idx].u.surface, context, location);
2117 }
Definition: http.c:6587
GLenum GLuint texture
Definition: glext.h:6295
BOOL surface_load_location(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location)
Definition: surface.c:2630

◆ texture2d_prepare_texture()

static void texture2d_prepare_texture ( struct wined3d_texture texture,
struct wined3d_context context,
BOOL  srgb 
)
static

Definition at line 2120 of file texture.c.

2121 {
2122  const struct wined3d_format *format = texture->resource.format;
2123  const struct wined3d_gl_info *gl_info = context->gl_info;
2124  const struct wined3d_color_key_conversion *conversion;
2125  GLenum internal;
2126 
2127  TRACE("texture %p, context %p, format %s.\n", texture, context, debug_d3dformat(format->id));
2128 
2129  if (format->conv_byte_count)
2130  {
2132  }
2133  else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
2134  {
2136  format = wined3d_get_format(gl_info, conversion->dst_format, texture->resource.usage);
2137  TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
2138  }
2139 
2141 
2142  if (srgb)
2143  internal = format->glGammaInternal;
2144  else if (texture->resource.usage & WINED3DUSAGE_RENDERTARGET
2145  && wined3d_resource_is_offscreen(&texture->resource))
2146  internal = format->rtInternal;
2147  else
2148  internal = format->glInternal;
2149 
2150  if (!internal)
2151  FIXME("No GL internal format for format %s.\n", debug_d3dformat(format->id));
2152 
2153  TRACE("internal %#x, format %#x, type %#x.\n", internal, format->glFormat, format->glType);
2154 
2157  else
2159 }
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(const struct wined3d_texture *texture, BOOL need_alpha_ck)
Definition: utils.c:1046
#define TRUE
Definition: types.h:120
Definition: http.c:6587
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:3824
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
static BOOL wined3d_texture_use_immutable_storage(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:42
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)
Definition: texture.c:518
enum wined3d_format_id dst_format
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
Definition: resource.c:547
unsigned int GLenum
Definition: gl.h:150
#define WINED3D_TEXTURE_CONVERTED
static void wined3d_texture_allocate_gl_immutable_storage(struct wined3d_texture *texture, GLenum gl_internal_format, const struct wined3d_gl_info *gl_info)
Definition: texture.c:564
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3973

◆ texture2d_upload_data()

static void texture2d_upload_data ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_context context,
const struct wined3d_box box,
const struct wined3d_const_bo_address data,
unsigned int  row_pitch,
unsigned int  slice_pitch 
)
static

Definition at line 2084 of file texture.c.

2087 {
2088  unsigned int texture_level;
2089  POINT dst_point;
2090  RECT src_rect;
2091 
2092  src_rect.left = 0;
2093  src_rect.top = 0;
2094  if (box)
2095  {
2096  dst_point.x = box->left;
2097  dst_point.y = box->top;
2098  src_rect.right = box->right - box->left;
2099  src_rect.bottom = box->bottom - box->top;
2100  }
2101  else
2102  {
2103  dst_point.x = dst_point.y = 0;
2104  texture_level = sub_resource_idx % texture->level_count;
2105  src_rect.right = wined3d_texture_get_level_width(texture, texture_level);
2106  src_rect.bottom = wined3d_texture_get_level_height(texture, texture_level);
2107  }
2108 
2109  wined3d_surface_upload_data(texture->sub_resources[sub_resource_idx].u.surface, context->gl_info,
2110  texture->resource.format, &src_rect, row_pitch, &dst_point, FALSE, data);
2111 }
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, BOOL srgb, const struct wined3d_const_bo_address *data)
Definition: surface.c:779
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LONG bottom
Definition: windef.h:294
Definition: palette.c:467

◆ texture3d_cleanup_sub_resources()

static void texture3d_cleanup_sub_resources ( struct wined3d_texture texture)
static

Definition at line 3152 of file texture.c.

3153 {
3154 }

◆ 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 2955 of file texture.c.

2957 {
2958  const struct wined3d_format *format = texture->resource.format;
2959  const struct wined3d_gl_info *gl_info = context->gl_info;
2960 
2961  if (format->conv_byte_count)
2962  {
2963  FIXME("Attempting to download a converted volume, format %s.\n",
2964  debug_d3dformat(format->id));
2965  return;
2966  }
2967 
2968  if (data->buffer_object)
2969  {
2970  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, data->buffer_object));
2971  checkGLcall("glBindBuffer");
2972  }
2973 
2974  gl_info->gl_ops.gl.p_glGetTexImage(GL_TEXTURE_3D, sub_resource_idx,
2975  format->glFormat, format->glType, data->addr);
2976  checkGLcall("glGetTexImage");
2977 
2978  if (data->buffer_object)
2979  {
2980  GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
2981  checkGLcall("glBindBuffer");
2982  }
2983 
2984 }
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:3973

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 3016 of file texture.c.

3018 {
3019  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
3020  unsigned int row_pitch, slice_pitch;
3021 
3022  if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location))
3023  return FALSE;
3024 
3025  switch (location)
3026  {
3029  if (sub_resource->locations & WINED3D_LOCATION_SYSMEM)
3030  {
3031  struct wined3d_const_bo_address data = {0, texture->resource.heap_memory};
3032  data.addr += sub_resource->offset;
3035  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
3036  texture3d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
3037  }
3038  else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
3039  {
3040 #if !defined(STAGING_CSMT)
3041  struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
3042 #else /* STAGING_CSMT */
3043  struct wined3d_const_bo_address data = {sub_resource->buffer->name, NULL};
3044 #endif /* STAGING_CSMT */
3047  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
3048  texture3d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
3049  }
3050  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3051  {
3052  texture3d_srgb_transfer(texture, sub_resource_idx, context, TRUE);
3053  }
3054  else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_SRGB)
3055  {
3056  texture3d_srgb_transfer(texture, sub_resource_idx, context, FALSE);
3057  }
3058  else
3059  {
3060  FIXME("Implement texture loading from %s.\n", wined3d_debug_location(sub_resource->locations));
3061  return FALSE;
3062  }
3063  break;
3064 
3066  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
3067  {
3068  struct wined3d_bo_address data = {0, texture->resource.heap_memory};
3069 
3070  data.addr += sub_resource->offset;
3071  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3073  else
3075 
3076  texture3d_download_data(texture, sub_resource_idx, context, &data);
3077  ++texture->download_count;
3078  }
3079  else
3080  {
3081  FIXME("Implement WINED3D_LOCATION_SYSMEM loading from %s.\n",
3082  wined3d_debug_location(sub_resource->locations));
3083  return FALSE;
3084  }
3085  break;
3086 
3088  if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
3089  {
3090 #if !defined(STAGING_CSMT)
3091  struct wined3d_bo_address data = {sub_resource->buffer_object, NULL};
3092 #else /* STAGING_CSMT */
3093  struct wined3d_bo_address data = {sub_resource->buffer->name, NULL};
3094 #endif /* STAGING_CSMT */
3095 
3096  if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
3098  else
3100 
3101  texture3d_download_data(texture, sub_resource_idx, context, &data);
3102  }
3103  else
3104  {
3105  FIXME("Implement WINED3D_LOCATION_BUFFER loading from %s.\n",
3106  wined3d_debug_location(sub_resource->locations));
3107  return FALSE;
3108  }
3109  break;
3110 
3111  default:
3112  FIXME("Implement %s loading from %s.\n", wined3d_debug_location(location),
3113  wined3d_debug_location(sub_resource->locations));
3114  return FALSE;
3115  }
3116 
3117  return TRUE;
3118 }
#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:2987
#define WINED3D_LOCATION_BUFFER
const char * wined3d_debug_location(DWORD location)
Definition: utils.c:6389
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:1605
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:2955
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WINED3D_LOCATION_SYSMEM
#define WINED3D_LOCATION_TEXTURE_RGB
static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: texture.c:2875
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
#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:1168

◆ texture3d_prepare_texture()

static void texture3d_prepare_texture ( struct wined3d_texture texture,
struct wined3d_context context,
BOOL  srgb 
)
static

Definition at line 3120 of file texture.c.

3121 {
3122  const struct wined3d_format *format = texture->resource.format;
3123  GLenum internal = srgb ? format->glGammaInternal : format->glInternal;
3124  unsigned int sub_count = texture->level_count * texture->layer_count;
3125  const struct wined3d_gl_info *gl_info = context->gl_info;
3126  unsigned int i;
3127 
3129 
3131  {
3132  GL_EXTCALL(glTexStorage3D(GL_TEXTURE_3D, texture->level_count, internal,
3136  checkGLcall("glTexStorage3D");
3137  }
3138  else
3139  {
3140  for (i = 0; i < sub_count; ++i)
3141  {
3146  0, format->glFormat, format->glType, NULL));
3147  checkGLcall("glTexImage3D");
3148  }
3149  }
3150 }
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)
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
static BOOL wined3d_texture_use_immutable_storage(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:42
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)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GL_TEXTURE_3D
Definition: gl.h:1515
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
unsigned int GLenum
Definition: gl.h:150
#define checkGLcall(A)
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868

◆ 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 2987 of file texture.c.

2989 {
2990  struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
2991  unsigned int row_pitch, slice_pitch;
2992  struct wined3d_bo_address data;
2993 
2994  /* Optimisations are possible, but the effort should be put into either
2995  * implementing EXT_SRGB_DECODE in the driver or finding out why we
2996  * picked the wrong copy for the original upload and fixing that.
2997  *
2998  * Also keep in mind that we want to avoid using resource.heap_memory
2999  * for DEFAULT pool surfaces. */
3000  WARN_(d3d_perf)("Performing slow rgb/srgb volume transfer.\n");
3001  data.buffer_object = 0;
3002  if (!(data.addr = heap_alloc(sub_resource->size)))
3003  return;
3004 
3005  wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
3007  texture3d_download_data(texture, sub_resource_idx, context, &data);
3009  texture3d_upload_data(texture, sub_resource_idx, context,
3010  NULL, wined3d_const_bo_address(&data), row_pitch, slice_pitch);
3011 
3012  heap_free(data.addr);
3013 }
Definition: http.c:6587
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
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:2955
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static struct wined3d_const_bo_address * wined3d_const_bo_address(struct wined3d_bo_address *data)
static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
Definition: texture.c:2875
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:868
#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:1168
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by texture3d_load_location().

◆ texture3d_upload_data()

static void texture3d_upload_data ( struct wined3d_texture texture,
unsigned int  sub_resource_idx,
const struct wined3d_context context,
const struct wined3d_box box,
const struct wined3d_const_bo_address data,
unsigned int  row_pitch,
unsigned int  slice_pitch 
)
static

Definition at line 2875 of file texture.c.

2878 {
2879  const struct wined3d_format *format = texture->resource.format;
2880  unsigned int level = sub_resource_idx % texture->level_count;
2881  const struct wined3d_gl_info *gl_info = context->gl_info;
2882  unsigned int x, y, z, update_w, update_h, update_d;
2883  unsigned int dst_row_pitch, dst_slice_pitch;
2884  unsigned int width, height, depth;
2885  const void *mem = data->addr;
2886  void *converted_mem = NULL;
2887 
2888  TRACE("texture %p, sub_resource_idx %u, context %p, box %s, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n",
2889  texture, sub_resource_idx, context, debug_box(box),
2890  data->buffer_object, data->addr, row_pitch, slice_pitch);
2891 
2895 
2896  if (!box)
2897  {
2898  x = y = z = 0;
2899  update_w = width;
2900  update_h = height;
2901  update_d = depth;
2902  }
2903  else
2904  {
2905  x = box->left;
2906  y = box->top;
2907  z = box->front;
2908  update_w = box->right - box->left;
2909  update_h = box->bottom - box->top;
2910  update_d = box->back - box->front;
2911  }
2912 
2913  if (format->conv_byte_count)
2914  {
2915  if (data->buffer_object)
2916  ERR("Loading a converted texture from a PBO.\n");
2917  if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
2918  ERR("Converting a block-based format.\n");
2919 
2920  dst_row_pitch = update_w * format->conv_byte_count;
2921  dst_slice_pitch = dst_row_pitch * update_h;
2922 
2923  converted_mem = heap_calloc(update_d, dst_slice_pitch);
2924  format->upload(data->addr, converted_mem, row_pitch, slice_pitch,
2925  dst_row_pitch, dst_slice_pitch, update_w, update_h, update_d);
2926  mem = converted_mem;
2927  }
2928  else
2929  {
2930  wined3d_texture_get_pitch(texture, sub_resource_idx, &dst_row_pitch, &dst_slice_pitch);
2931  if (row_pitch != dst_row_pitch || slice_pitch != dst_slice_pitch)
2932  FIXME("Ignoring row/slice pitch (%u/%u).\n", row_pitch, slice_pitch);
2933  }
2934 
2935  if (data->buffer_object)
2936  {
2937  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object));
2938  checkGLcall("glBindBuffer");
2939  }
2940 
2942  update_w, update_h, update_d, format->glFormat, format->glType, mem));
2943  checkGLcall("glTexSubImage3D");
2944 
2945  if (data->buffer_object)
2946  {
2947  GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
2948  checkGLcall("glBindBuffer");
2949  }
2950 
2951  heap_free(converted_mem);
2952 }
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)
Definition: http.c:6587
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#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:3932
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
#define FIXME(fmt,...)
Definition: debug.h:110
GLdouble GLdouble z
Definition: glext.h:5874
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_PIXEL_UNPACK_BUFFER
Definition: glext.h:477
smooth NULL
Definition: ftsmooth.c:416
#define GL_EXTCALL(f)
#define TRACE(s)
Definition: solgame.cpp:4
GLAPI void GLAPIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels)
GLenum GLuint texture
Definition: glext.h:6295
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:109
#define checkGLcall(A)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
Definition: mem.c:156
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1168
Definition: palette.c:467
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by texture3d_load_location(), and texture3d_srgb_transfer().

◆ texture_init()

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

Definition at line 2641 of file texture.c.

2644 {
2645  struct wined3d_device_parent *device_parent = device->device_parent;
2646  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
2647  struct wined3d_surface *surfaces;
2648  UINT pow2_width, pow2_height;
2649  unsigned int i, j, sub_count;
2650  HRESULT hr;
2651 
2652  if (!(desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) && layer_count > 1
2653  && !gl_info->supported[EXT_TEXTURE_ARRAY])
2654  {
2655  WARN("OpenGL implementation does not support array textures.\n");
2656  return WINED3DERR_INVALIDCALL;
2657  }
2658 
2659  /* TODO: It should only be possible to create textures for formats
2660  * that are reported as supported. */
2661  if (WINED3DFMT_UNKNOWN >= desc->format)
2662  {
2663  WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
2664  return WINED3DERR_INVALIDCALL;
2665  }
2666 
2668  FIXME("Trying to create a managed texture with dynamic usage.\n");
2671  WARN("Creating a mappable texture that doesn't specify dynamic usage.\n");
2673  FIXME("Trying to create a CPU accessible render target.\n");
2674 
2675  pow2_width = desc->width;
2676  pow2_height = desc->height;
2677  if (((desc->width & (desc->width - 1)) || (desc->height & (desc->height - 1)))
2679  {
2680  /* level_count == 0 returns an error as well. */
2681  if (level_count != 1 || layer_count != 1)
2682  {
2683  if (!(desc->usage & WINED3DUSAGE_SCRATCH))
2684  {
2685  WARN("Attempted to create a mipmapped/cube/array NPOT texture without unconditional NPOT support.\n");
2686  return WINED3DERR_INVALIDCALL;
2687  }
2688 
2689  WARN("Creating a scratch mipmapped/cube/array NPOT texture despite lack of HW support.\n");
2690  }
2692 
2694  {
2695  const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format, desc->usage);
2696 
2697  /* TODO: Add support for non-power-of-two compressed textures. */
2700  {
2701  FIXME("Compressed or height scaled non-power-of-two (%ux%u) textures are not supported.\n",
2702  desc->width, desc->height);
2703  return WINED3DERR_NOTAVAILABLE;
2704  }
2705 
2706  /* Find the nearest pow2 match. */
2707  pow2_width = pow2_height = 1;
2708  while (pow2_width < desc->width)
2709  pow2_width <<= 1;
2710  while (pow2_height < desc->height)
2711  pow2_height <<= 1;
2713  }
2714  }
2715  texture->pow2_width = pow2_width;
2716  texture->pow2_height = pow2_height;
2717 
2718  if ((pow2_width > gl_info->limits.texture_size || pow2_height > gl_info->limits.texture_size)
2719  && (desc->usage & WINED3DUSAGE_TEXTURE))
2720  {
2721  /* One of four options:
2722  * 1: Do the same as we do with NPOT and scale the texture. (Any
2723  * texture ops would require the texture to be scaled which is
2724  * potentially slow.)
2725  * 2: Set the texture to the maximum size (bad idea).
2726  * 3: WARN and return WINED3DERR_NOTAVAILABLE.
2727  * 4: Create the surface, but allow it to be used only for DirectDraw
2728  * Blts. Some apps (e.g. Swat 3) create textures with a height of
2729  * 16 and a width > 3000 and blt 16x16 letter areas from them to
2730  * the render target. */
2731  if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
2732  {
2733  WARN("Dimensions (%ux%u) exceed the maximum texture size.\n", pow2_width, pow2_height);
2734  return WINED3DERR_NOTAVAILABLE;
2735  }
2736 
2737  /* We should never use this surface in combination with OpenGL. */
2738  TRACE("Creating an oversized (%ux%u) surface.\n", pow2_width, pow2_height);
2739  }
2740 
2741  if (FAILED(hr = wined3d_texture_init(texture, &texture2d_ops, layer_count, level_count, desc,
2742  flags, device, parent, parent_ops, &texture_resource_ops)))
2743  {
2744  WARN("Failed to initialize texture, returning %#x.\n", hr);
2745  return hr;
2746  }
2747 
2748  /* Precalculated scaling for 'faked' non power of two texture coords. */
2749  if (texture->resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT)
2750  {
2751  texture->pow2_matrix[0] = (float)desc->width;
2752  texture->pow2_matrix[5] = (float)desc->height;
2755  }
2756  else
2757  {
2759  {
2760  texture->pow2_matrix[0] = (((float)desc->width) / ((float)pow2_width));
2761  texture->pow2_matrix[5] = (((float)desc->height) / ((float)pow2_height));
2763  }
2764  else
2765  {
2766  texture->pow2_matrix[0] = 1.0f;
2767  texture->pow2_matrix[5] = 1.0f;
2768  }
2769  if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
2770  {
2771  texture->target = GL_TEXTURE_CUBE_MAP_ARB;
2772  }
2773  else if (desc->multisample_type && gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
2774  {
2775  if (layer_count > 1)
2777  else
2779  }
2780  else
2781  {
2782  if (layer_count > 1)
2783  texture->target = GL_TEXTURE_2D_ARRAY;
2784  else
2785  texture->target = GL_TEXTURE_2D;
2786  }
2787  }
2788  texture->pow2_matrix[10] = 1.0f;
2789  texture->pow2_matrix[15] = 1.0f;
2790  TRACE("x scale %.8e, y scale %.8e.\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
2791 
2792  if (wined3d_texture_use_pbo(texture, gl_info))
2793  texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
2794 
2795  sub_count = level_count * layer_count;
2796  if (sub_count / layer_count != level_count
2797  || !(surfaces = heap_calloc(sub_count, sizeof(*surfaces))))
2798  {
2800  return E_OUTOFMEMORY;
2801  }
2802 
2803  if (desc->usage & WINED3DUSAGE_OVERLAY)
2804  {
2805  if (!(texture->overlay_info = heap_calloc(sub_count, sizeof(*texture->overlay_info))))
2806  {
2809  return E_OUTOFMEMORY;
2810  }
2811 
2812  for (i = 0; i < sub_count; ++i)
2813  {
2814  list_init(&texture->overlay_info[i].entry);
2815  list_init(&texture->overlay_info[i].overlays);
2816  }
2817  }
2818 
2819  /* Generate all the surfaces. */
2820  for (i = 0; i < texture->level_count; ++i)
2821  {
2822  for (j = 0; j < texture->layer_count; ++j)
2823  {
2824  struct wined3d_texture_sub_resource *sub_resource;
2825  unsigned int idx = j * texture->level_count + i;
2826  struct wined3d_surface *surface;
2827 
2828  surface = &surfaces[idx];
2829  surface->container = texture;
2830  surface->texture_level = i;
2831  surface->texture_layer = j;
2832  list_init(&surface->renderbuffers);
2833 
2834  sub_resource = &texture->sub_resources[idx];
2835  sub_resource->locations = WINED3D_LOCATION_DISCARDED;
2836  sub_resource->u.surface = surface;
2837  if (!(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
2838  {
2841  }
2842 
2843  if (FAILED(hr = device_parent->ops->surface_created(device_parent,
2844  texture, idx, &sub_resource->parent, &sub_resource->parent_ops)))
2845  {
2846  WARN("Failed to create surface parent, hr %#x.\n", hr);
2847  sub_resource->parent = NULL;
2849  return hr;
2850  }
2851 
2852  TRACE("parent %p, parent_ops %p.\n", sub_resource->parent, sub_resource->parent_ops);
2853 
2854  TRACE("Created surface level %u, layer %u @ %p.\n", i, j, surface);
2855 
2856  if ((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D))
2857  {
2859  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
2860  if (!surface->dc)
2861  {
2863  return WINED3DERR_INVALIDCALL;
2864  }
2865  }
2866  }
2867  }
2868 
2869  return WINED3D_OK;
2870 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
GLint GLint GLsizei width
Definition: gl.h:1546
#define WINED3DUSAGE_OVERLAY
Definition: wined3d.h:921
HRESULT hr
Definition: shlfolder.c:183
static const struct wined3d_texture_ops texture2d_ops
Definition: texture.c:2202
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:907
#define WINED3D_TEXTURE_POW2_MAT_IDENT
#define WARN(fmt,...)
Definition: debug.h:111
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:3824
static void texture2d_create_dc(void *object)
Definition: texture.c:1255
#define WINED3D_LOCATION_BUFFER
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1890
const GLvdpauSurfaceNV * surfaces
Definition: glext.h:11586
#define WINED3DUSAGE_DEPTHSTENCIL
Definition: wined3d.h:900
unsigned int texture_level
#define WINED3D_TEXTURE_COND_NP2
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
static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
Definition: texture.c:1009
#define GL_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1230
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:56
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_RECTANGLE_ARB
Definition: glext.h:1614
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
static BOOL wined3d_resource_access_is_managed(unsigned int access)
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL supported[WINED3D_GL_EXT_COUNT]
unsigned int idx
Definition: utils.c:41
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define WINED3DUSAGE_LEGACY_CUBEMAP
Definition: wined3d.h:917
static const struct wined3d_resource_ops texture_resource_ops
Definition: texture.c:2507
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
r parent
Definition: btrfs.c:2897
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:77
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:899
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
#define WINED3D_TEXTURE_NORMALIZED_COORDS
#define WINED3D_LOCATION_SYSMEM
const struct wined3d_device_parent_ops * ops
Definition: wined3d.h:2133
#define WINED3DFMT_FLAG_HEIGHT_SCALE
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
unsigned int texture_layer
struct list renderbuffers
#define WINED3D_TEXTURE_CREATE_MAPPABLE
Definition: wined3d.h:1558
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:159
static BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:33
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:46
#define WINED3DUSAGE_TEXTURE
Definition: wined3d.h:918
unsigned int UINT
Definition: ndis.h:50
#define GL_TEXTURE_2D
Definition: gl.h:645
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:915
#define WINED3DFMT_FLAG_COMPRESSED
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define WINED3D_TEXTURE_COND_NP2_EMULATED
#define WINED3D_LOCATION_DISCARDED
struct wined3d_texture * container
#define WINED3DUSAGE_OWNDC
Definition: wined3d.h:919
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
Definition: texture.c:323
#define WINED3D_NO3D
Definition: wined3d.h:1316
struct wined3d_gl_limits limits
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ texture_resource_decref()

static ULONG texture_resource_decref ( struct wined3d_resource resource)
static

Definition at line 2220 of file texture.c.

2221 {
2223 }
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1023

◆ texture_resource_incref()

static ULONG texture_resource_incref ( struct wined3d_resource resource)
static

Definition at line 2215 of file texture.c.

2216 {
2218 }
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:994

◆ texture_resource_preload()

static void texture_resource_preload ( struct wined3d_resource resource)
static

Definition at line 2225 of file texture.c.

2226 {
2228  struct wined3d_context *context;
2229 
2230  context = context_acquire(resource->device, NULL, 0);
2233 }
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:1571
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:4242
void wined3d_texture_load(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
Definition: texture.c:1066

◆ 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 2302 of file texture.c.

2304 {
2305  const struct wined3d_format *format = resource->format;
2306  struct wined3d_texture_sub_resource *sub_resource;
2307  struct wined3d_device *device = resource->device;
2308  unsigned int fmt_flags = resource->format_flags;
2309  struct wined3d_context *context = NULL;
2310  struct wined3d_texture *texture;
2311  struct wined3d_bo_address data;
2312  unsigned int texture_level;
2313  BYTE *base_memory;
2314  BOOL ret;
2315 
2316  TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
2317  resource, sub_resource_idx, map_desc, debug_box(box), flags);
2318 
2320  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2321  return E_INVALIDARG;
2322 
2323  texture_level = sub_resource_idx % texture->level_count;
2324  if (box && FAILED(wined3d_texture_check_box_dimensions(texture, texture_level, box)))
2325  {
2326  WARN("Map box is invalid.\n");
2327  if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
2328  || resource->type != WINED3D_RTYPE_TEXTURE_2D)
2329  return WINED3DERR_INVALIDCALL;
2330  }
2331 
2332  if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
2333  {
2334  WARN("DC is in use.\n");
2335  return WINED3DERR_INVALIDCALL;
2336  }
2337 
2338  if (sub_resource->map_count)
2339  {
2340  WARN("Sub-resource is already mapped.\n");
2341  return WINED3DERR_INVALIDCALL;
2342  }
2343 
2344  if (device->d3d_initialized)
2346 
2347  if (flags & WINED3D_MAP_DISCARD)
2348  {
2349  TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n",
2350  wined3d_debug_location(resource->map_binding));
2351  if ((ret = wined3d_texture_prepare_location(texture, sub_resource_idx, context, resource->map_binding)))
2352  wined3d_texture_validate_location(texture, sub_resource_idx, resource->map_binding);
2353  }
2354  else
2355  {
2356  if (resource->usage & WINED3DUSAGE_DYNAMIC)
2357  WARN_(d3d_perf)("Mapping a dynamic texture without WINED3D_MAP_DISCARD.\n");
2358  ret = wined3d_texture_load_location(texture, sub_resource_idx, context, resource->map_binding);
2359  }
2360 
2361  if (!ret)
2362  {
2363  ERR("Failed to prepare location.\n");
2365  return E_OUTOFMEMORY;
2366  }
2367 
2368  if (flags & WINED3D_MAP_WRITE
2370  wined3d_texture_invalidate_location(texture, sub_resource_idx, ~resource->map_binding);
2371 
2372  wined3d_texture_get_memory(texture, sub_resource_idx, &data, resource->map_binding);
2373  base_memory = context_map_bo_address(context, &data, sub_resource->size, GL_PIXEL_UNPACK_BUFFER, flags);
2374  TRACE("Base memory pointer %p.\n", base_memory);
2375 
2376  if (context)
2378 
2379  if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
2380  {
2381  map_desc->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count;
2382  map_desc->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * map_desc->row_pitch;
2383  }
2384  else
2385  {
2386  wined3d_texture_get_pitch(texture, texture_level, &map_desc->row_pitch, &map_desc->slice_pitch);
2387  }
2388 
2389  if (!box)
2390  {
2391  map_desc->data = base_memory;
2392  }
2393  else
2394  {
2396  {
2397  /* Compressed textures are block based, so calculate the offset of
2398  * the block that contains the top-left pixel of the mapped box. */
2399  map_desc->data = base_memory
2400  + (box->front * map_desc->slice_pitch)
2401  + ((box->top / format->block_height) * map_desc->row_pitch)
2402  + ((box->left / format->block_width) * format->block_byte_count);
2403  }
2404  else
2405  {
2406  map_desc->data = base_memory
2407  + (box->front * map_desc->slice_pitch)
2408  + (box->top * map_desc->row_pitch)
2409  + (box->left * format->byte_count);
2410  }
2411  }
2412 
2413  if (texture->swapchain && texture->swapchain->front_buffer == texture)
2414  {
2415  RECT *r = &texture->swapchain->front_buffer_update;
2416 
2417  if (!box)
2418  SetRect(r, 0, 0, resource->width, resource->height);
2419  else
2420  SetRect(r, box->left, box->top, box->right, box->bottom);
2421  TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
2422  }
2423 
2424  ++resource->map_count;
2425  ++sub_resource->map_count;
2426 
2427  TRACE("Returning memory %p, row pitch %u, slice pitch %u.\n",
2428  map_desc->data, map_desc->row_pitch, map_desc->slice_pitch);
2429 
2430  return WINED3D_OK;
2431 }
#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:907
#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:3932
HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture, unsigned int level, const struct wined3d_box *box)
Definition: texture.c:1128
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:6389
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:285
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#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:1605
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:935
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:135
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:937
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
int ret
#define WINED3D_MAP_WRITE
Definition: wined3d.h:938
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:4242
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:159
void * context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags)
Definition: context.c:2802
static struct wined3d_texture_sub_resource * wined3d_texture_get_sub_resource(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:1661
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:229
#define 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:1168
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 2433 of file texture.c.

2435 {
2436  const struct wined3d_format *format = resource->format;
2437  struct wined3d_texture_sub_resource *sub_resource;
2438  unsigned int fmt_flags = resource->format_flags;
2439  struct wined3d_texture *texture;
2440  unsigned int texture_level;
2441 
2443  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2444  return E_INVALIDARG;
2445 
2446  texture_level = sub_resource_idx % texture->level_count;
2447 
2448  if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
2449  {
2450  info->row_pitch = wined3d_texture_get_level_width(texture, texture_level) * format->byte_count;
2451  info->slice_pitch = wined3d_texture_get_level_height(texture, texture_level) * info->row_pitch;
2452  }
2453  else
2454  {
2455  wined3d_texture_get_pitch(texture, texture_level, &info->row_pitch, &info->slice_pitch);
2456  }
2457 
2458  info->size = info->slice_pitch * wined3d_texture_get_level_depth(texture, texture_level);
2459 
2460  return WINED3D_OK;
2461 }
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:1661
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1168

◆ 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 2463 of file texture.c.

2464 {
2465  struct wined3d_texture_sub_resource *sub_resource;
2466  struct wined3d_device *device = resource->device;
2467  struct wined3d_context *context = NULL;
2468  struct wined3d_texture *texture;
2469  struct wined3d_bo_address data;
2470 
2471  TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
2472 
2474  if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
2475  return E_INVALIDARG;
2476 
2477  if (!sub_resource->map_count)
2478  {
2479  WARN("Trying to unmap unmapped sub-resource.\n");
2480  if (texture->flags & WINED3D_TEXTURE_DC_IN_USE)
2481  return WINED3D_OK;
2482  return WINEDDERR_NOTLOCKED;
2483  }
2484 
2485  if (device->d3d_initialized)
2487 
2488  wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding);
2490 
2491  if (context)
2493 
2494  if (texture->swapchain && texture->swapchain->front_buffer == texture)
2495  {
2496  if (!(sub_resource->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)))
2497  texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(texture->swapchain);
2498  }
2499 
2500  --sub_resource->map_count;
2501  if (!--resource->map_count && texture->update_map_binding)
2503 
2504  return WINED3D_OK;
2505 }
void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding)
Definition: context.c:2831
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:285
void context_release(struct wined3d_context *context)
Definition: context.c:1571
#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:437
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4242
#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:1661

◆ volumetexture_init()

static HRESULT volumetexture_init ( struct wined3d_texture texture,
const struct wined3d_resource_desc desc,
UINT  layer_count,
UINT  level_count,
DWORD  flags,
struct wined3d_device device,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 3164 of file texture.c.

3167 {
3168  struct wined3d_device_parent *device_parent = device->device_parent;
3169  const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
3170  unsigned int i;
3171  HRESULT hr;
3172 
3173  if (layer_count != 1)
3174  {
3175  ERR("Invalid layer count for volume texture.\n");
3176  return E_INVALIDARG;
3177  }
3178 
3179  /* TODO: It should only be possible to create textures for formats
3180  * that are reported as supported. */
3181  if (WINED3DFMT_UNKNOWN >= desc->format)
3182  {
3183  WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
3184  return WINED3DERR_INVALIDCALL;
3185  }
3186 
3187  if (!gl_info->supported[EXT_TEXTURE3D])
3188  {
3189  WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
3190  return WINED3DERR_INVALIDCALL;
3191  }
3192 
3194  || desc->usage & WINED3DUSAGE_SCRATCH))
3195  {
3196  WARN("Attempted to create a DYNAMIC texture with access %s.\n",
3198  return WINED3DERR_INVALIDCALL;
3199  }
3200 
3201  if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
3202  {
3203  if (!is_power_of_two(desc->width) || !is_power_of_two(desc->height) || !is_power_of_two(desc->depth))
3204  {
3205  if (desc->usage & WINED3DUSAGE_SCRATCH)
3206  {
3207  WARN("Creating a scratch NPOT volume texture despite lack of HW support.\n");
3208  }
3209  else
3210  {
3211  WARN("Attempted to create a NPOT volume texture (%u, %u, %u) without GL support.\n",
3212  desc->width, desc->height, desc->depth);
3213  return WINED3DERR_INVALIDCALL;
3214  }
3215  }
3216  }
3217 
3218  if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, level_count, desc,
3219  flags, device, parent, parent_ops, &texture_resource_ops)))
3220  {
3221  WARN("Failed to initialize texture, returning %#x.\n", hr);
3222  return hr;
3223  }
3224 
3225  texture->pow2_matrix[0] = 1.0f;
3226  texture->pow2_matrix[5] = 1.0f;
3227  texture->pow2_matrix[10] = 1.0f;
3228  texture->pow2_matrix[15] = 1.0f;
3229  texture->target = GL_TEXTURE_3D;
3230 
3231  if (wined3d_texture_use_pbo(texture, gl_info))
3232  {
3234  texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
3235  }
3236 
3237  /* Generate all the sub resources. */
3238  for (i = 0; i < texture->level_count; ++i)
3239  {
3240  struct wined3d_texture_sub_resource *sub_resource;
3241 
3242  sub_resource = &texture->sub_resources[i];
3243  sub_resource->locations = WINED3D_LOCATION_DISCARDED;
3244 
3245  if (FAILED(hr = device_parent->ops->volume_created(device_parent,
3246  texture, i, &sub_resource->parent, &sub_resource->parent_ops)))
3247  {
3248  WARN("Failed to create volume parent, hr %#x.\n", hr);
3249  sub_resource->parent = NULL;
3251  return hr;
3252  }
3253 
3254  TRACE("parent %p, parent_ops %p.\n", parent, parent_ops);
3255 
3256  TRACE("Created volume level %u.\n", i);
3257  }
3258 
3259  return WINED3D_OK;
3260 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
HRESULT hr
Definition: shlfolder.c:183
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:907
#define WARN(fmt,...)
Definition: debug.h:111
#define WINED3D_LOCATION_BUFFER
static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
Definition: texture.c:1009
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
static BOOL wined3d_resource_access_is_managed(unsigned int access)
BOOL supported[WINED3D_GL_EXT_COUNT]
#define E_INVALIDARG
Definition: ddrawi.h:101
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define GL_TEXTURE_3D
Definition: gl.h:1515
smooth NULL
Definition: ftsmooth.c:416
static const struct wined3d_resource_ops texture_resource_ops
Definition: texture.c:2507
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2897
GLenum GLuint texture
Definition: glext.h:6295
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
static BOOL is_power_of_two(UINT x)
Definition: texture.c:104
const struct wined3d_device_parent_ops * ops
Definition: wined3d.h:2133
#define ERR(fmt,...)
Definition: debug.h:109
static const struct wined3d_texture_ops texture3d_ops
Definition: texture.c:3156
static BOOL wined3d_texture_use_pbo(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
Definition: texture.c:33
#define WINED3DUSAGE_SCRATCH
Definition: wined3d.h:915
#define WINED3D_LOCATION_DISCARDED
const char * wined3d_debug_resource_access(DWORD access)
Definition: utils.c:4193
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_texture_ops *texture_ops, UINT layer_count, UINT level_count, const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_resource_ops *resource_ops)
Definition: texture.c:323
void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
Definition: resource.c:504

◆ 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 79 of file texture.c.

80 {
81  switch (location)
82  {
84  return 0;
85 
89 
97 
98  default:
99  FIXME("Unhandled location %#x.\n", location);
100  return 0;
101  }
102 }
#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 texture1d_load_location(), and 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 1677 of file texture.c.

1679 {
1680  TRACE("texture %p, layer %u, dirty_region %s.\n", texture, layer, debug_box(dirty_region));
1681 
1682  if (layer >= texture->layer_count)
1683  {
1684  WARN("Invalid layer %u specified.\n", layer);
1685  return WINED3DERR_INVALIDCALL;
1686  }
1687 
1688  if (dirty_region)
1689  WARN("Ignoring dirty_region %s.\n", debug_box(dirty_region));
1690 
1692 
1693  return WINED3D_OK;
1694 }
#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:3932
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:2353

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 564 of file texture.c.

566 {
570 
571  switch (texture->target)
572  {
573  case GL_TEXTURE_2D_ARRAY:
574  GL_EXTCALL(glTexStorage3D(texture->target, texture->level_count,
575  gl_internal_format, width, height, texture->layer_count));
576  break;
578  GL_EXTCALL(glTexStorage2DMultisample(texture->target, samples,
579  gl_internal_format, width, height, GL_FALSE));
580  break;
582  GL_EXTCALL(glTexStorage3DMultisample(texture->target, samples,
583  gl_internal_format, width, height, texture->layer_count, GL_FALSE));
584  break;
585  default:
586  GL_EXTCALL(glTexStorage2D(texture->target, texture->level_count,
587  gl_internal_format, width, height));
588  break;
589  }
590 
591  checkGLcall("allocate immutable storage");
592 }
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:484
#define GL_FALSE
Definition: gl.h:173
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
int GLsizei
Definition: gl.h:160
#define GL_EXTCALL(f)
GLenum GLuint texture
Definition: glext.h:6295
#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 texture2d_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 518 of file texture.c.

521 {
522  unsigned int level, level_count, layer, layer_count;
524  GLenum target;
525 
526  level_count = texture->level_count;
527  layer_count = texture->target == GL_TEXTURE_2D_ARRAY ? 1 : texture->layer_count;
528 
529  for (layer = 0; layer < layer_count; ++layer)
530  {
532 
533  for (level = 0; level < level_count; ++level)
534  {
537  if (texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
538  {
539  height *= format->height_scale.numerator;
540  height /= format->height_scale.denominator;
541  }
542 
543  TRACE("texture %p, layer %u, level %u, target %#x, width %u, height %u.\n",
545 
546  if (texture->target == GL_TEXTURE_2D_ARRAY)
547  {
548  GL_EXTCALL(glTexImage3D(target, level, gl_internal_format, width, height,
549  texture->layer_count, 0, format->glFormat, format->glType, NULL));
550  checkGLcall("glTexImage3D");
551  }
552  else
553  {
554  gl_info->gl_ops.gl.p_glTexImage2D(target, level, gl_internal_format,
555  width, height, 0, format->glFormat, format->glType, NULL);
556  checkGLcall("glTexImage2D");
557  }
558  }
559  }
560 }
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
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)
int GLsizei
Definition: gl.h:160
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_2D_ARRAY
Definition: glext.h:535
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 texture2d_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 896 of file texture.c.

898 {
899  const struct wined3d_gl_info *gl_info = context->gl_info;
900  GLenum target = texture->target;
901  struct gl_texture *gl_tex;
902  DWORD state;
903 
904  TRACE("texture %p, sampler_desc %p, context %p.\n", texture, sampler_desc, context);
905 
907 
908  state = sampler_desc->address_u;
909  if (state != gl_tex->sampler_desc.address_u)
910  {
911  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S,
913  gl_tex->sampler_desc.address_u = state;
914  }
915 
916  state = sampler_desc->address_v;
917  if (state != gl_tex->sampler_desc.address_v)
918  {
919  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T,
921  gl_tex->sampler_desc.address_v = state;
922  }
923 
924  state = sampler_desc->address_w;
925  if (state != gl_tex->sampler_desc.address_w)
926  {
927  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_R,
929  gl_tex->sampler_desc.address_w = state;
930  }
931 
932  if (memcmp(gl_tex->sampler_desc.border_color, sampler_desc->border_color,
933  sizeof(gl_tex->sampler_desc.border_color)))
934  {
935  gl_info->gl_ops.gl.p_glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, &sampler_desc->border_color[0]);
936  memcpy(gl_tex->sampler_desc.border_color, sampler_desc->border_color,
937  sizeof(gl_tex->sampler_desc.border_color));
938  }
939 
940  state = sampler_desc->mag_filter;
941  if (state != gl_tex->sampler_desc.mag_filter)
942  {
943  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, wined3d_gl_mag_filter(state));
944  gl_tex->sampler_desc.mag_filter = state;
945  }
946 
947  if (sampler_desc->min_filter != gl_tex->sampler_desc.min_filter
948  || sampler_desc->mip_filter != gl_tex->sampler_desc.mip_filter)
949  {
950  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
951  wined3d_gl_min_mip_filter(sampler_desc->min_filter, sampler_desc->mip_filter));
952  gl_tex->sampler_desc.min_filter = sampler_desc->min_filter;
953  gl_tex->sampler_desc.mip_filter = sampler_desc->mip_filter;
954  }
955 
956  state = sampler_desc->max_anisotropy;
957  if (state != gl_tex->sampler_desc.max_anisotropy)
958  {
960  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_ANISOTROPY, state);
961  else
962  WARN("Anisotropic filtering not supported.\n");
963  gl_tex->sampler_desc.max_anisotropy = state;
964  }
965 
966  if (!sampler_desc->srgb_decode != !gl_tex->sampler_desc.srgb_decode
967  && (context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
968  && gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
969  {
970  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT,
972  gl_tex->sampler_desc.srgb_decode = sampler_desc->srgb_decode;
973  }
974 
975  if (!sampler_desc->compare != !gl_tex->sampler_desc.compare)
976  {
977  if (sampler_desc->compare)
978  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
979  else
980  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
981  gl_tex->sampler_desc.compare = sampler_desc->compare;
982  }
983 
984  checkGLcall("Texture parameter application");
985 
986  if (gl_info->supported[EXT_TEXTURE_LOD_BIAS])
987  {
988  gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
990  checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
991  }
992 }
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:1324
#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 729 of file texture.c.

731 {
732  const struct wined3d_gl_info *gl_info = context->gl_info;
733  const struct wined3d_format *format = texture->resource.format;
734  const struct color_fixup_desc fixup = format->color_fixup;
735  struct gl_texture *gl_tex;
736  GLenum target;
737 
738  TRACE("texture %p, context %p, srgb %#x.\n", texture, context, srgb);
739 
741  srgb = FALSE;
742 
743  /* sRGB mode cache for preload() calls outside drawprim. */
744  if (srgb)
746  else
747  texture->flags &= ~WINED3D_TEXTURE_IS_SRGB;
748 
749  gl_tex = wined3d_texture_get_gl_texture(texture, srgb);
750  target = texture->target;
751 
752  if (gl_tex->name)
753  {
755  return;
756  }
757 
758  gl_info->gl_ops.gl.p_glGenTextures(1, &gl_tex->name);
759  checkGLcall("glGenTextures");
760  TRACE("Generated texture %d.\n", gl_tex->name);
761 
762  if (!gl_tex->name)
763  {
764  ERR("Failed to generate a texture name.\n");
765  return;
766  }
767 
768  /* Initialise the state of the texture object to the OpenGL defaults, not
769  * the wined3d defaults. */
770  gl_tex->sampler_desc.address_u = WINED3D_TADDRESS_WRAP;
771  gl_tex->sampler_desc.address_v = WINED3D_TADDRESS_WRAP;
772  gl_tex->sampler_desc.address_w = WINED3D_TADDRESS_WRAP;
773  memset(gl_tex->sampler_desc.border_color, 0, sizeof(gl_tex->sampler_desc.border_color));
774  gl_tex->sampler_desc.mag_filter = WINED3D_TEXF_LINEAR;
775  gl_tex->sampler_desc.min_filter = WINED3D_TEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
776  gl_tex->sampler_desc.mip_filter = WINED3D_TEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
777  gl_tex->sampler_desc.lod_bias = 0.0f;
778  gl_tex->sampler_desc.min_lod = -1000.0f;
779  gl_tex->sampler_desc.max_lod = 1000.0f;
780  gl_tex->sampler_desc.max_anisotropy = 1;
781  gl_tex->sampler_desc.compare = FALSE;
782  gl_tex->sampler_desc.comparison_func = WINED3D_CMP_LESSEQUAL;
783  if (context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
784  gl_tex->sampler_desc.srgb_decode = TRUE;
785  else
786  gl_tex->sampler_desc.srgb_decode = srgb;
787  gl_tex->base_level = 0;
789 
791 
792  /* For a new texture we have to set the texture levels after binding the
793  * texture. Beware that texture rectangles do not support mipmapping, but
794  * set the maxmiplevel if we're relying on the partial
795  * GL_ARB_texture_non_power_of_two emulation with texture rectangles.
796  * (I.e., do not care about cond_np2 here, just look for
797  * GL_TEXTURE_RECTANGLE_ARB.) */
799  {
800  TRACE("Setting GL_TEXTURE_MAX_LEVEL to %u.\n", texture->level_count - 1);
801  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count - 1);
802  checkGLcall("glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, texture->level_count)");
803  }
804 
806  {
807  /* Cubemaps are always set to clamp, regardless of the sampler state. */
808  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
809  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
810  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
811  }
812 
813  if (texture->flags & WINED3D_TEXTURE_COND_NP2)
814  {
815  /* Conditinal non power of two textures use a different clamping
816  * default. If we're using the GL_WINE_normalized_texrect partial
817  * driver emulation, we're dealing with a GL_TEXTURE_2D texture which
818  * has the address mode set to repeat - something that prevents us
819  * from hitting the accelerated codepath. Thus manually set the GL
820  * state. The same applies to filtering. Even if the texture has only
821  * one mip level, the default LINEAR_MIPMAP_LINEAR filter causes a SW
822  * fallback on macos. */
823  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
824  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
825  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
826  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
827  checkGLcall("glTexParameteri");
828  gl_tex->sampler_desc.address_u = WINED3D_TADDRESS_CLAMP;
829  gl_tex->sampler_desc.address_v = WINED3D_TADDRESS_CLAMP;
830  gl_tex->sampler_desc.mag_filter = WINED3D_TEXF_POINT;
831  gl_tex->sampler_desc.min_filter = WINED3D_TEXF_POINT;
832  gl_tex->sampler_desc.mip_filter = WINED3D_TEXF_NONE;
833  }
834 
836  {
837  gl_info->gl_ops.gl.p_glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY);
838  checkGLcall("glTexParameteri(GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY)");
839  }
840 
841  if (!is_identity_fixup(fixup) && can_use_texture_swizzle(gl_info, format))
842  {
843  static const GLenum swizzle_source[] =
844  {
845  GL_ZERO, /* CHANNEL_SOURCE_ZERO */
846  GL_ONE, /* CHANNEL_SOURCE_ONE */
847  GL_RED, /* CHANNEL_SOURCE_X */
848  GL_GREEN, /* CHANNEL_SOURCE_Y */
849  GL_BLUE, /* CHANNEL_SOURCE_Z */
850  GL_ALPHA, /* CHANNEL_SOURCE_W */
851  };
852  struct
853  {
854  GLint x, y, z, w;
855  }
856  swizzle;
857 
858  swizzle.x = swizzle_source[fixup.x_source];
859  swizzle.y = swizzle_source[fixup.y_source];
860  swizzle.z = swizzle_source[fixup.z_source];
861  swizzle.w = swizzle_source[fixup.w_source];
862  gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, &swizzle.x);
863  checkGLcall("glTexParameteriv(GL_TEXTURE_SWIZZLE_RGBA)");
864  }
865 }
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:2734
#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:154
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 868 of file texture.c.

870 {
871  /* We don't need a specific texture unit, but after binding the texture
872  * the current unit is dirty. Read the unit back instead of switching to
873  * 0, this avoids messing around with the state manager's GL states. The
874  * current texture unit should always be a valid one.
875  *
876  * To be more specific, this is tricky because we can implicitly be
877  * called from sampler() in state.c. This means we can't touch anything
878  * other than whatever happens to be the currently active texture, or we
879  * would risk marking already applied sampler states dirty again. */
880  if (context->active_texture < ARRAY_SIZE(context->rev_tex_unit_map))
881  {
882  DWORD active_sampler = context->rev_tex_unit_map[context->active_texture];
883  if (active_sampler != WINED3D_UNMAPPED_STAGE)
885  }
886  /* FIXME: Ideally we'd only do this when touching a binding that's used by
887  * a shader. */
890 
892 }
Definition: http.c:6587
void context_invalidate_state(struct wined3d_context *context, DWORD state)
Definition: context.c:1652
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:1642
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:729

Referenced by shader_resource_view_generate_mipmaps(), surface_convert_format(), surface_load_fb_texture(), surface_load_sysmem(), surface_load_texture(), surface_upload_from_surface(), texture1d_load_location(), texture1d_prepare_texture(), texture1d_srgb_transfer(), texture2d_prepare_texture(), texture3d_load_location(), texture3d_prepare_texture(), texture3d_srgb_transfer(), wined3d_cs_exec_blt_sub_resource(), and wined3d_cs_exec_update_sub_resource().

◆ 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 3262 of file texture.c.

3265 {
3266  struct wined3d_box src_box = {src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1};
3267  struct wined3d_box dst_box = {dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, 0, 1};
3268  unsigned int dst_format_flags, src_format_flags = 0;
3269  HRESULT hr;
3270 
3271  TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_rect %s, src_texture %p, "
3272  "src_sub_resource_idx %u, src_rect %s, flags %#x, fx %p, filter %s.\n",
3273  dst_texture, dst_sub_resource_idx, wine_dbgstr_rect(dst_rect), src_texture,
3274  src_sub_resource_idx, wine_dbgstr_rect(src_rect), flags, fx, debug_d3dtexturefiltertype(filter));
3275 
3276  if (dst_sub_resource_idx >= dst_texture->level_count * dst_texture->layer_count
3277  || dst_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
3278  return WINED3DERR_INVALIDCALL;
3279 
3280  if (src_sub_resource_idx >= src_texture->level_count * src_texture->layer_count
3281  || src_texture->resource.type != WINED3D_RTYPE_TEXTURE_2D)
3282  return WINED3DERR_INVALIDCALL;
3283 
3284  dst_format_flags = dst_texture->resource.format_flags;
3286  dst_sub_resource_idx % dst_texture->level_count, &dst_box)))
3287  return hr;
3288 
3289  src_format_flags = src_texture->resource.format_flags;
3291  src_sub_resource_idx % src_texture->level_count, &src_box)))
3292  return hr;
3293 
3294  if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
3295  || src_texture->sub_resources[src_sub_resource_idx].map_count)
3296  {
3297 #if !defined(STAGING_CSMT)
3298  WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
3299  return WINEDDERR_SURFACEBUSY;
3300 #else /* STAGING_CSMT */
3301  struct wined3d_device *device = dst_texture->resource.device;
3302  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
3303  if (dst_texture->sub_resources[dst_sub_resource_idx].map_count
3304  || (src_texture && src_texture->sub_resources[src_sub_resource_idx].map_count))
3305  {
3306  WARN("Sub-resource is busy, returning WINEDDERR_SURFACEBUSY.\n");
3307  return WINEDDERR_SURFACEBUSY;
3308  }
3309 #endif /* STAGING_CSMT */
3310  }
3311 
3312  if ((src_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
3313  != (dst_format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
3314  {
3315  WARN("Rejecting depth/stencil blit between incompatible formats.\n");
3316  return WINED3DERR_INVALIDCALL;
3317  }
3318 
3319  wined3d_cs_emit_blt_sub_resource(dst_texture->resource.device->cs, &dst_texture->resource, dst_sub_resource_idx,
3320  &dst_box, &src_texture->resource, src_sub_resource_idx, &src_box, flags, fx, filter);
3321 
3322  return WINED3D_OK;
3323 }
#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:1128
LONG right
Definition: windef.h:293
Definition: devices.h:37
#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:4532
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
GLfixed fx
Definition: tritemp.h:482
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:2172
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 1128 of file texture.c.

1130 {
1131  const struct wined3d_format *format = texture->resource.format;
1132  unsigned int width_mask, height_mask, width, height, depth;
1133 
1137 
1138  if (box->left >= box->right || box->right > width
1139  || box->top >= box->bottom || box->bottom > height
1140  || box->front >= box->back || box->back > depth)
1141  {
1142  WARN("Box %s is invalid.\n", debug_box(box));
1143  return WINEDDERR_INVALIDRECT;
1144  }
1145 
1146  if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
1147  {
1148  /* This assumes power of two block sizes, but NPOT block sizes would
1149  * be silly anyway.
1150  *
1151  * This also assumes that the format's block depth is 1. */
1152  width_mask = format->block_width - 1;
1153  height_mask = format->block_height - 1;
1154 
1155  if ((box->left & width_mask) || (box->top & height_mask)
1156  || (box->right & width_mask && box->right != width)
1157  || (box->bottom & height_mask && box->bottom != height))
1158  {
1159  WARN("Box %s is misaligned for %ux%u blocks.\n",
1160  debug_box(box), format->block_width, format->block_height);
1161  return WINED3DERR_INVALIDCALL;
1162  }
1163  }
1164 
1165  return WINED3D_OK;
1166 }
#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:3932
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLenum GLuint texture
Definition: