wined3d: Pass wined3d_adapter to wined3d_get_format().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4df05c37db
commit
9320424105
|
@ -1323,8 +1323,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
|
||||||
UINT size, DWORD usage, enum wined3d_format_id format_id, unsigned int access, unsigned int bind_flags,
|
UINT size, DWORD usage, enum wined3d_format_id format_id, unsigned int access, unsigned int bind_flags,
|
||||||
const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops)
|
const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops)
|
||||||
{
|
{
|
||||||
|
const struct wined3d_format *format = wined3d_get_format(device->adapter, format_id, usage);
|
||||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||||
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, usage);
|
|
||||||
struct wined3d_resource *resource = &buffer->resource;
|
struct wined3d_resource *resource = &buffer->resource;
|
||||||
struct wined3d_box box;
|
struct wined3d_box box;
|
||||||
BOOL dynamic_buffer_ok;
|
BOOL dynamic_buffer_ok;
|
||||||
|
|
|
@ -2060,9 +2060,9 @@ BOOL wined3d_adapter_opengl_create_context(struct wined3d_context *context,
|
||||||
aux_buffers = TRUE;
|
aux_buffers = TRUE;
|
||||||
|
|
||||||
if (color_format->id == WINED3DFMT_B4G4R4X4_UNORM)
|
if (color_format->id == WINED3DFMT_B4G4R4X4_UNORM)
|
||||||
color_format = wined3d_get_format(gl_info, WINED3DFMT_B4G4R4A4_UNORM, target_usage);
|
color_format = wined3d_get_format(device->adapter, WINED3DFMT_B4G4R4A4_UNORM, target_usage);
|
||||||
else if (color_format->id == WINED3DFMT_B8G8R8X8_UNORM)
|
else if (color_format->id == WINED3DFMT_B8G8R8X8_UNORM)
|
||||||
color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
color_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DirectDraw supports 8bit paletted render targets and these are used by
|
/* DirectDraw supports 8bit paletted render targets and these are used by
|
||||||
|
@ -2072,7 +2072,7 @@ BOOL wined3d_adapter_opengl_create_context(struct wined3d_context *context,
|
||||||
* For this reason we require a format with 8bit alpha, so request
|
* For this reason we require a format with 8bit alpha, so request
|
||||||
* A8R8G8B8. */
|
* A8R8G8B8. */
|
||||||
if (color_format->id == WINED3DFMT_P8_UINT)
|
if (color_format->id == WINED3DFMT_P8_UINT)
|
||||||
color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
color_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
||||||
|
|
||||||
/* When using FBOs for off-screen rendering, we only use the drawable for
|
/* When using FBOs for off-screen rendering, we only use the drawable for
|
||||||
* presentation blits, and don't do any rendering to it. That means we
|
* presentation blits, and don't do any rendering to it. That means we
|
||||||
|
@ -2084,8 +2084,8 @@ BOOL wined3d_adapter_opengl_create_context(struct wined3d_context *context,
|
||||||
* conflicting pixel formats. */
|
* conflicting pixel formats. */
|
||||||
if (wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER)
|
if (wined3d_settings.offscreen_rendering_mode != ORM_BACKBUFFER)
|
||||||
{
|
{
|
||||||
color_format = wined3d_get_format(gl_info, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
color_format = wined3d_get_format(device->adapter, WINED3DFMT_B8G8R8A8_UNORM, target_usage);
|
||||||
ds_format = wined3d_get_format(gl_info, WINED3DFMT_UNKNOWN, WINED3DUSAGE_DEPTHSTENCIL);
|
ds_format = wined3d_get_format(device->adapter, WINED3DFMT_UNKNOWN, WINED3DUSAGE_DEPTHSTENCIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to find a pixel format which matches our requirements. */
|
/* Try to find a pixel format which matches our requirements. */
|
||||||
|
|
|
@ -739,7 +739,7 @@ UINT CDECL wined3d_get_adapter_mode_count(const struct wined3d *wined3d, UINT ad
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
adapter = &wined3d->adapters[adapter_idx];
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
|
format = wined3d_get_format(adapter, format_id, WINED3DUSAGE_RENDERTARGET);
|
||||||
format_bits = format->byte_count * CHAR_BIT;
|
format_bits = format->byte_count * CHAR_BIT;
|
||||||
|
|
||||||
memset(&mode, 0, sizeof(mode));
|
memset(&mode, 0, sizeof(mode));
|
||||||
|
@ -793,7 +793,7 @@ HRESULT CDECL wined3d_enum_adapter_modes(const struct wined3d *wined3d, UINT ada
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
adapter = &wined3d->adapters[adapter_idx];
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
format = wined3d_get_format(&adapter->gl_info, format_id, WINED3DUSAGE_RENDERTARGET);
|
format = wined3d_get_format(adapter, format_id, WINED3DUSAGE_RENDERTARGET);
|
||||||
format_bits = format->byte_count * CHAR_BIT;
|
format_bits = format->byte_count * CHAR_BIT;
|
||||||
|
|
||||||
memset(&m, 0, sizeof(m));
|
memset(&m, 0, sizeof(m));
|
||||||
|
@ -1052,7 +1052,7 @@ HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d,
|
||||||
TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
|
TRACE("mode %ux%u@%u %s %#x.\n", mode->width, mode->height, mode->refresh_rate,
|
||||||
debug_d3dformat(mode->format_id), mode->scanline_ordering);
|
debug_d3dformat(mode->format_id), mode->scanline_ordering);
|
||||||
|
|
||||||
format = wined3d_get_format(&adapter->gl_info, mode->format_id, WINED3DUSAGE_RENDERTARGET);
|
format = wined3d_get_format(adapter, mode->format_id, WINED3DUSAGE_RENDERTARGET);
|
||||||
|
|
||||||
new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
new_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
|
new_mode.dmBitsPerPel = format->byte_count * CHAR_BIT;
|
||||||
|
@ -1294,8 +1294,8 @@ HRESULT CDECL wined3d_check_depth_stencil_match(const struct wined3d *wined3d,
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
adapter = &wined3d->adapters[adapter_idx];
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
rt_format = wined3d_get_format(&adapter->gl_info, render_target_format_id, WINED3DUSAGE_RENDERTARGET);
|
rt_format = wined3d_get_format(adapter, render_target_format_id, WINED3DUSAGE_RENDERTARGET);
|
||||||
ds_format = wined3d_get_format(&adapter->gl_info, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL);
|
ds_format = wined3d_get_format(adapter, depth_stencil_format_id, WINED3DUSAGE_DEPTHSTENCIL);
|
||||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
||||||
{
|
{
|
||||||
if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
|
if ((rt_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_RENDERTARGET)
|
||||||
|
@ -1335,8 +1335,8 @@ HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3
|
||||||
enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
|
enum wined3d_device_type device_type, enum wined3d_format_id surface_format_id, BOOL windowed,
|
||||||
enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
|
enum wined3d_multisample_type multisample_type, DWORD *quality_levels)
|
||||||
{
|
{
|
||||||
const struct wined3d_gl_info *gl_info = &wined3d->adapters[adapter_idx].gl_info;
|
const struct wined3d_adapter *adapter;
|
||||||
const struct wined3d_format *format = wined3d_get_format(gl_info, surface_format_id, 0);
|
const struct wined3d_format *format;
|
||||||
HRESULT hr = WINED3D_OK;
|
HRESULT hr = WINED3D_OK;
|
||||||
|
|
||||||
TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
|
TRACE("wined3d %p, adapter_idx %u, device_type %s, surface_format %s, "
|
||||||
|
@ -1356,6 +1356,9 @@ HRESULT CDECL wined3d_check_device_multisample_type(const struct wined3d *wined3
|
||||||
return WINED3DERR_NOTAVAILABLE;
|
return WINED3DERR_NOTAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
|
format = wined3d_get_format(adapter, surface_format_id, 0);
|
||||||
|
|
||||||
if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
|
if (multisample_type && !(format->multisample_types & 1u << (multisample_type - 1)))
|
||||||
hr = WINED3DERR_NOTAVAILABLE;
|
hr = WINED3DERR_NOTAVAILABLE;
|
||||||
|
|
||||||
|
@ -1525,10 +1528,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
||||||
enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
|
enum wined3d_device_type device_type, enum wined3d_format_id adapter_format_id, DWORD usage,
|
||||||
enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
|
enum wined3d_resource_type resource_type, enum wined3d_format_id check_format_id)
|
||||||
{
|
{
|
||||||
const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx];
|
|
||||||
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
|
||||||
const struct wined3d_format *adapter_format, *format;
|
const struct wined3d_format *adapter_format, *format;
|
||||||
enum wined3d_gl_resource_type gl_type, gl_type_end;
|
enum wined3d_gl_resource_type gl_type, gl_type_end;
|
||||||
|
const struct wined3d_adapter *adapter;
|
||||||
BOOL mipmap_gen_supported = TRUE;
|
BOOL mipmap_gen_supported = TRUE;
|
||||||
DWORD format_flags = 0;
|
DWORD format_flags = 0;
|
||||||
DWORD allowed_usage;
|
DWORD allowed_usage;
|
||||||
|
@ -1542,8 +1544,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
||||||
if (adapter_idx >= wined3d->adapter_count)
|
if (adapter_idx >= wined3d->adapter_count)
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
adapter_format = wined3d_get_format(gl_info, adapter_format_id, WINED3DUSAGE_RENDERTARGET);
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
format = wined3d_get_format(gl_info, check_format_id, usage);
|
adapter_format = wined3d_get_format(adapter, adapter_format_id, WINED3DUSAGE_RENDERTARGET);
|
||||||
|
format = wined3d_get_format(adapter, check_format_id, usage);
|
||||||
|
|
||||||
switch (resource_type)
|
switch (resource_type)
|
||||||
{
|
{
|
||||||
|
@ -1604,7 +1607,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
||||||
}
|
}
|
||||||
else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
||||||
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
|
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
|
||||||
&& !gl_info->supported[ARB_SHADOW])
|
&& !adapter->gl_info.supported[ARB_SHADOW])
|
||||||
{
|
{
|
||||||
TRACE("[FAILED] - No shadow sampler support.\n");
|
TRACE("[FAILED] - No shadow sampler support.\n");
|
||||||
return WINED3DERR_NOTAVAILABLE;
|
return WINED3DERR_NOTAVAILABLE;
|
||||||
|
@ -1702,7 +1705,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
||||||
UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
|
UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT adapter_idx,
|
||||||
enum wined3d_format_id format_id, UINT width)
|
enum wined3d_format_id format_id, UINT width)
|
||||||
{
|
{
|
||||||
const struct wined3d_gl_info *gl_info;
|
const struct wined3d_adapter *adapter;
|
||||||
unsigned int row_pitch, slice_pitch;
|
unsigned int row_pitch, slice_pitch;
|
||||||
|
|
||||||
TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
|
TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
|
||||||
|
@ -1711,8 +1714,8 @@ UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT ad
|
||||||
if (adapter_idx >= wined3d->adapter_count)
|
if (adapter_idx >= wined3d->adapter_count)
|
||||||
return ~0u;
|
return ~0u;
|
||||||
|
|
||||||
gl_info = &wined3d->adapters[adapter_idx].gl_info;
|
adapter = &wined3d->adapters[adapter_idx];
|
||||||
wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id, 0),
|
wined3d_format_calculate_pitch(wined3d_get_format(adapter, format_id, 0),
|
||||||
1, width, 1, &row_pitch, &slice_pitch);
|
1, width, 1, &row_pitch, &slice_pitch);
|
||||||
|
|
||||||
return row_pitch;
|
return row_pitch;
|
||||||
|
|
|
@ -478,11 +478,11 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wined3d_format *wined3d_resource_get_decompress_format(struct wined3d_resource *resource,
|
const struct wined3d_format *wined3d_resource_get_decompress_format(struct wined3d_resource *resource)
|
||||||
const struct wined3d_context *context)
|
|
||||||
{
|
{
|
||||||
|
const struct wined3d_adapter *adapter = resource->device->adapter;
|
||||||
if (resource->format_flags & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)
|
if (resource->format_flags & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)
|
||||||
&& !(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
|
&& !(adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
|
||||||
return wined3d_get_format(context->gl_info, WINED3DFMT_B8G8R8A8_UNORM_SRGB, resource->usage);
|
return wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM_SRGB, resource->usage);
|
||||||
return wined3d_get_format(context->gl_info, WINED3DFMT_B8G8R8A8_UNORM, resource->usage);
|
return wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, resource->usage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1833,7 +1833,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
|
||||||
|
|
||||||
format = texture->resource.format;
|
format = texture->resource.format;
|
||||||
if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
|
if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
|
||||||
format = wined3d_get_format(gl_info, conversion->dst_format, texture->resource.usage);
|
format = wined3d_get_format(device->adapter, conversion->dst_format, texture->resource.usage);
|
||||||
|
|
||||||
/* Don't use PBOs for converted surfaces. During PBO conversion we look at
|
/* Don't use PBOs for converted surfaces. During PBO conversion we look at
|
||||||
* WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
|
* WINED3D_TEXTURE_CONVERTED but it isn't set (yet) in all cases it is
|
||||||
|
|
|
@ -659,6 +659,7 @@ static void swapchain_update_render_to_fbo(struct wined3d_swapchain *swapchain)
|
||||||
static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_swapchain *swapchain,
|
static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_swapchain *swapchain,
|
||||||
enum wined3d_format_id format_id, enum wined3d_multisample_type *type, DWORD *quality)
|
enum wined3d_format_id format_id, enum wined3d_multisample_type *type, DWORD *quality)
|
||||||
{
|
{
|
||||||
|
const struct wined3d_adapter *adapter;
|
||||||
const struct wined3d_gl_info *gl_info;
|
const struct wined3d_gl_info *gl_info;
|
||||||
const struct wined3d_format *format;
|
const struct wined3d_format *format;
|
||||||
enum wined3d_multisample_type t;
|
enum wined3d_multisample_type t;
|
||||||
|
@ -666,8 +667,9 @@ static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_s
|
||||||
if (wined3d_settings.sample_count == ~0u)
|
if (wined3d_settings.sample_count == ~0u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gl_info = &swapchain->device->adapter->gl_info;
|
adapter = swapchain->device->adapter;
|
||||||
if (!(format = wined3d_get_format(gl_info, format_id, WINED3DUSAGE_RENDERTARGET)))
|
gl_info = &adapter->gl_info;
|
||||||
|
if (!(format = wined3d_get_format(adapter, format_id, WINED3DUSAGE_RENDERTARGET)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((t = min(wined3d_settings.sample_count, gl_info->limits.samples)))
|
if ((t = min(wined3d_settings.sample_count, gl_info->limits.samples)))
|
||||||
|
@ -706,7 +708,7 @@ void wined3d_swapchain_set_swap_interval(struct wined3d_swapchain *swapchain,
|
||||||
static void wined3d_swapchain_cs_init(void *object)
|
static void wined3d_swapchain_cs_init(void *object)
|
||||||
{
|
{
|
||||||
struct wined3d_swapchain *swapchain = object;
|
struct wined3d_swapchain *swapchain = object;
|
||||||
const struct wined3d_gl_info *gl_info;
|
const struct wined3d_adapter *adapter;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
static const enum wined3d_format_id formats[] =
|
static const enum wined3d_format_id formats[] =
|
||||||
|
@ -718,13 +720,13 @@ static void wined3d_swapchain_cs_init(void *object)
|
||||||
WINED3DFMT_S1_UINT_D15_UNORM,
|
WINED3DFMT_S1_UINT_D15_UNORM,
|
||||||
};
|
};
|
||||||
|
|
||||||
gl_info = &swapchain->device->adapter->gl_info;
|
adapter = swapchain->device->adapter;
|
||||||
|
|
||||||
/* Without ORM_FBO, switching the depth/stencil format is hard. Always
|
/* Without ORM_FBO, switching the depth/stencil format is hard. Always
|
||||||
* request a depth/stencil buffer in the likely case it's needed later. */
|
* request a depth/stencil buffer in the likely case it's needed later. */
|
||||||
for (i = 0; i < ARRAY_SIZE(formats); ++i)
|
for (i = 0; i < ARRAY_SIZE(formats); ++i)
|
||||||
{
|
{
|
||||||
swapchain->ds_format = wined3d_get_format(gl_info, formats[i], WINED3DUSAGE_DEPTHSTENCIL);
|
swapchain->ds_format = wined3d_get_format(adapter, formats[i], WINED3DUSAGE_DEPTHSTENCIL);
|
||||||
if ((swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
|
if ((swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
|
||||||
break;
|
break;
|
||||||
TRACE("Depth stencil format %s is not supported, trying next format.\n", debug_d3dformat(formats[i]));
|
TRACE("Depth stencil format %s is not supported, trying next format.\n", debug_d3dformat(formats[i]));
|
||||||
|
|
|
@ -1535,11 +1535,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
|
||||||
enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type,
|
enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type,
|
||||||
UINT multisample_quality, void *mem, UINT pitch)
|
UINT multisample_quality, void *mem, UINT pitch)
|
||||||
{
|
{
|
||||||
struct wined3d_device *device = texture->resource.device;
|
|
||||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
|
||||||
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, texture->resource.usage);
|
|
||||||
UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
|
|
||||||
struct wined3d_texture_sub_resource *sub_resource;
|
struct wined3d_texture_sub_resource *sub_resource;
|
||||||
|
const struct wined3d_gl_info *gl_info;
|
||||||
|
const struct wined3d_format *format;
|
||||||
|
struct wined3d_device *device;
|
||||||
|
unsigned int resource_size;
|
||||||
DWORD valid_location = 0;
|
DWORD valid_location = 0;
|
||||||
BOOL create_dib = FALSE;
|
BOOL create_dib = FALSE;
|
||||||
|
|
||||||
|
@ -1547,6 +1547,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
|
||||||
"mem %p, pitch %u.\n",
|
"mem %p, pitch %u.\n",
|
||||||
texture, width, height, debug_d3dformat(format_id), multisample_type, multisample_quality, mem, pitch);
|
texture, width, height, debug_d3dformat(format_id), multisample_type, multisample_quality, mem, pitch);
|
||||||
|
|
||||||
|
device = texture->resource.device;
|
||||||
|
gl_info = &device->adapter->gl_info;
|
||||||
|
format = wined3d_get_format(device->adapter, format_id, texture->resource.usage);
|
||||||
|
resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
|
||||||
|
|
||||||
if (!resource_size)
|
if (!resource_size)
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
@ -1706,6 +1711,7 @@ 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)
|
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
|
||||||
{
|
{
|
||||||
DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED;
|
DWORD alloc_flag = srgb ? WINED3D_TEXTURE_SRGB_ALLOCATED : WINED3D_TEXTURE_RGB_ALLOCATED;
|
||||||
|
const struct wined3d_device *device = texture->resource.device;
|
||||||
const struct wined3d_format *format = texture->resource.format;
|
const struct wined3d_format *format = texture->resource.format;
|
||||||
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
||||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||||
|
@ -1731,7 +1737,7 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
|
||||||
{
|
{
|
||||||
TRACE("WINED3DFMT_FLAG_DECOMPRESS set.\n");
|
TRACE("WINED3DFMT_FLAG_DECOMPRESS set.\n");
|
||||||
texture->flags |= WINED3D_TEXTURE_CONVERTED;
|
texture->flags |= WINED3D_TEXTURE_CONVERTED;
|
||||||
format = wined3d_resource_get_decompress_format(&texture->resource, context);
|
format = wined3d_resource_get_decompress_format(&texture->resource);
|
||||||
}
|
}
|
||||||
else if (format->conv_byte_count)
|
else if (format->conv_byte_count)
|
||||||
{
|
{
|
||||||
|
@ -1740,7 +1746,7 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct win
|
||||||
else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
|
else if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
|
||||||
{
|
{
|
||||||
texture->flags |= WINED3D_TEXTURE_CONVERTED;
|
texture->flags |= WINED3D_TEXTURE_CONVERTED;
|
||||||
format = wined3d_get_format(gl_info, conversion->dst_format, texture->resource.usage);
|
format = wined3d_get_format(device->adapter, conversion->dst_format, texture->resource.usage);
|
||||||
TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
|
TRACE("Using format %s for color key conversion.\n", debug_d3dformat(format->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1964,7 +1970,7 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s
|
||||||
|
|
||||||
if (decompress)
|
if (decompress)
|
||||||
{
|
{
|
||||||
format = wined3d_resource_get_decompress_format(&texture->resource, context);
|
format = wined3d_resource_get_decompress_format(&texture->resource);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2613,6 +2619,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
|
||||||
WARN("Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n");
|
WARN("Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n");
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
format = wined3d_get_format(device->adapter, desc->format, desc->usage);
|
||||||
|
|
||||||
if (desc->usage & WINED3DUSAGE_DYNAMIC && (wined3d_resource_access_is_managed(desc->access)
|
if (desc->usage & WINED3DUSAGE_DYNAMIC && (wined3d_resource_access_is_managed(desc->access)
|
||||||
|| desc->usage & WINED3DUSAGE_SCRATCH))
|
|| desc->usage & WINED3DUSAGE_SCRATCH))
|
||||||
|
@ -2650,7 +2657,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
|
||||||
if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE]
|
if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE]
|
||||||
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
|
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
|
||||||
{
|
{
|
||||||
const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format, desc->usage);
|
|
||||||
|
|
||||||
/* TODO: Add support for non-power-of-two compressed textures. */
|
/* TODO: Add support for non-power-of-two compressed textures. */
|
||||||
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
|
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
|
||||||
|
@ -2696,7 +2702,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
|
||||||
TRACE("Creating an oversized (%ux%u) surface.\n", pow2_width, pow2_height);
|
TRACE("Creating an oversized (%ux%u) surface.\n", pow2_width, pow2_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
format = wined3d_get_format(&device->adapter->gl_info, desc->format, desc->usage);
|
|
||||||
for (i = 0; i < layer_count; ++i)
|
for (i = 0; i < layer_count; ++i)
|
||||||
{
|
{
|
||||||
for (j = 0; j < level_count; ++j)
|
for (j = 0; j < level_count; ++j)
|
||||||
|
@ -2929,7 +2934,6 @@ static void texture3d_download_data(struct wined3d_texture *texture, unsigned in
|
||||||
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
|
||||||
checkGLcall("glBindBuffer");
|
checkGLcall("glBindBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Context activation is done by the caller. */
|
/* Context activation is done by the caller. */
|
||||||
|
@ -3349,8 +3353,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
|
||||||
|
|
||||||
if (desc->multisample_type != WINED3D_MULTISAMPLE_NONE)
|
if (desc->multisample_type != WINED3D_MULTISAMPLE_NONE)
|
||||||
{
|
{
|
||||||
const struct wined3d_format *format = wined3d_get_format(&device->adapter->gl_info,
|
const struct wined3d_format *format = wined3d_get_format(device->adapter, desc->format, desc->usage);
|
||||||
desc->format, desc->usage);
|
|
||||||
|
|
||||||
if (desc->multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE
|
if (desc->multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE
|
||||||
&& desc->multisample_quality >= wined3d_popcount(format->multisample_types))
|
&& desc->multisample_quality >= wined3d_popcount(format->multisample_types))
|
||||||
|
|
|
@ -3994,9 +3994,10 @@ fail:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
|
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
|
||||||
enum wined3d_format_id format_id, unsigned int resource_usage)
|
enum wined3d_format_id format_id, unsigned int resource_usage)
|
||||||
{
|
{
|
||||||
|
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
||||||
const struct wined3d_format *format;
|
const struct wined3d_format *format;
|
||||||
int idx = get_format_idx(format_id);
|
int idx = get_format_idx(format_id);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
|
@ -173,7 +173,8 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
|
||||||
struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count,
|
struct wined3d_device *device, const struct wined3d_vertex_element *elements, UINT element_count,
|
||||||
void *parent, const struct wined3d_parent_ops *parent_ops)
|
void *parent, const struct wined3d_parent_ops *parent_ops)
|
||||||
{
|
{
|
||||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
const struct wined3d_adapter *adapter = device->adapter;
|
||||||
|
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (TRACE_ON(d3d_decl))
|
if (TRACE_ON(d3d_decl))
|
||||||
|
@ -201,7 +202,7 @@ static HRESULT vertexdeclaration_init(struct wined3d_vertex_declaration *declara
|
||||||
{
|
{
|
||||||
struct wined3d_vertex_declaration_element *e = &declaration->elements[i];
|
struct wined3d_vertex_declaration_element *e = &declaration->elements[i];
|
||||||
|
|
||||||
e->format = wined3d_get_format(gl_info, elements[i].format, 0);
|
e->format = wined3d_get_format(adapter, elements[i].format, 0);
|
||||||
e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
|
e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
|
||||||
e->input_slot = elements[i].input_slot;
|
e->input_slot = elements[i].input_slot;
|
||||||
e->offset = elements[i].offset;
|
e->offset = elements[i].offset;
|
||||||
|
@ -289,10 +290,10 @@ HRESULT CDECL wined3d_vertex_declaration_create(struct wined3d_device *device,
|
||||||
|
|
||||||
struct wined3d_fvf_convert_state
|
struct wined3d_fvf_convert_state
|
||||||
{
|
{
|
||||||
const struct wined3d_gl_info *gl_info;
|
const struct wined3d_adapter *adapter;
|
||||||
struct wined3d_vertex_element *elements;
|
struct wined3d_vertex_element *elements;
|
||||||
UINT offset;
|
unsigned int offset;
|
||||||
UINT idx;
|
unsigned int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void append_decl_element(struct wined3d_fvf_convert_state *state,
|
static void append_decl_element(struct wined3d_fvf_convert_state *state,
|
||||||
|
@ -313,12 +314,12 @@ static void append_decl_element(struct wined3d_fvf_convert_state *state,
|
||||||
elements[idx].usage = usage;
|
elements[idx].usage = usage;
|
||||||
elements[idx].usage_idx = usage_idx;
|
elements[idx].usage_idx = usage_idx;
|
||||||
|
|
||||||
format = wined3d_get_format(state->gl_info, format_id, 0);
|
format = wined3d_get_format(state->adapter, format_id, 0);
|
||||||
state->offset += format->attribute_size;
|
state->offset += format->attribute_size;
|
||||||
++state->idx;
|
++state->idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_info,
|
static unsigned int convert_fvf_to_declaration(const struct wined3d_adapter *adapter,
|
||||||
DWORD fvf, struct wined3d_vertex_element **elements)
|
DWORD fvf, struct wined3d_vertex_element **elements)
|
||||||
{
|
{
|
||||||
BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
|
BOOL has_pos = !!(fvf & WINED3DFVF_POSITION_MASK);
|
||||||
|
@ -344,7 +345,7 @@ static unsigned int convert_fvf_to_declaration(const struct wined3d_gl_info *gl_
|
||||||
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
|
size = has_pos + (has_blend && num_blends > 0) + has_blend_idx + has_normal +
|
||||||
has_psize + has_diffuse + has_specular + num_textures;
|
has_psize + has_diffuse + has_specular + num_textures;
|
||||||
|
|
||||||
state.gl_info = gl_info;
|
state.adapter = adapter;
|
||||||
if (!(state.elements = heap_calloc(size, sizeof(*state.elements))))
|
if (!(state.elements = heap_calloc(size, sizeof(*state.elements))))
|
||||||
return ~0u;
|
return ~0u;
|
||||||
state.offset = 0;
|
state.offset = 0;
|
||||||
|
@ -440,8 +441,9 @@ HRESULT CDECL wined3d_vertex_declaration_create_from_fvf(struct wined3d_device *
|
||||||
TRACE("device %p, fvf %#x, parent %p, parent_ops %p, declaration %p.\n",
|
TRACE("device %p, fvf %#x, parent %p, parent_ops %p, declaration %p.\n",
|
||||||
device, fvf, parent, parent_ops, declaration);
|
device, fvf, parent, parent_ops, declaration);
|
||||||
|
|
||||||
size = convert_fvf_to_declaration(&device->adapter->gl_info, fvf, &elements);
|
size = convert_fvf_to_declaration(device->adapter, fvf, &elements);
|
||||||
if (size == ~0U) return E_OUTOFMEMORY;
|
if (size == ~0u)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
hr = wined3d_vertex_declaration_create(device, elements, size, parent, parent_ops, declaration);
|
hr = wined3d_vertex_declaration_create(device, elements, size, parent, parent_ops, declaration);
|
||||||
heap_free(elements);
|
heap_free(elements);
|
||||||
|
|
|
@ -84,10 +84,10 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info,
|
||||||
static const struct wined3d_format *validate_resource_view(const struct wined3d_view_desc *desc,
|
static const struct wined3d_format *validate_resource_view(const struct wined3d_view_desc *desc,
|
||||||
struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
|
struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
|
||||||
{
|
{
|
||||||
const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info;
|
const struct wined3d_adapter *adapter = resource->device->adapter;
|
||||||
const struct wined3d_format *format;
|
const struct wined3d_format *format;
|
||||||
|
|
||||||
format = wined3d_get_format(gl_info, desc->format_id, resource->usage);
|
format = wined3d_get_format(adapter, desc->format_id, resource->usage);
|
||||||
if (resource->type == WINED3D_RTYPE_BUFFER && (desc->flags & WINED3D_VIEW_BUFFER_RAW))
|
if (resource->type == WINED3D_RTYPE_BUFFER && (desc->flags & WINED3D_VIEW_BUFFER_RAW))
|
||||||
{
|
{
|
||||||
if (format->id != WINED3DFMT_R32_TYPELESS)
|
if (format->id != WINED3DFMT_R32_TYPELESS)
|
||||||
|
@ -96,7 +96,7 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
format = wined3d_get_format(gl_info, WINED3DFMT_R32_UINT, resource->usage);
|
format = wined3d_get_format(adapter, WINED3DFMT_R32_UINT, resource->usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wined3d_format_is_typeless(format))
|
if (wined3d_format_is_typeless(format))
|
||||||
|
@ -118,7 +118,7 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
format = wined3d_get_format(gl_info, WINED3DFMT_R32_UINT, resource->usage);
|
format = wined3d_get_format(adapter, WINED3DFMT_R32_UINT, resource->usage);
|
||||||
element_size = buffer->desc.structure_byte_stride;
|
element_size = buffer->desc.structure_byte_stride;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3136,8 +3136,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
||||||
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||||
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||||
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||||
const struct wined3d_format *wined3d_resource_get_decompress_format(struct wined3d_resource *resource,
|
const struct wined3d_format *wined3d_resource_get_decompress_format(
|
||||||
const struct wined3d_context *context) DECLSPEC_HIDDEN;
|
struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||||
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
||||||
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
||||||
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||||
|
@ -4371,7 +4371,7 @@ struct wined3d_format
|
||||||
GLenum gl_view_class;
|
GLenum gl_view_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
|
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
|
||||||
enum wined3d_format_id format_id, unsigned int resource_usage) DECLSPEC_HIDDEN;
|
enum wined3d_format_id format_id, unsigned int resource_usage) DECLSPEC_HIDDEN;
|
||||||
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
|
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
|
||||||
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
|
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue