mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 04:49:47 +00:00
wined3d: Unify WINED3D_RTYPE_TEXTURE and WINED3D_RTYPE_CUBE_TEXTURE.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
12ce3c58ed
commit
dafaae7730
|
@ -462,7 +462,7 @@ static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_devi
|
|||
if (desc->SampleDesc.Count > 1)
|
||||
FIXME("Multisampled textures not implemented.\n");
|
||||
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format);
|
||||
wined3d_desc.multisample_type = desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE;
|
||||
wined3d_desc.multisample_quality = desc->SampleDesc.Quality;
|
||||
|
|
|
@ -619,7 +619,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
|
|||
{
|
||||
struct d3d8_surface *surface;
|
||||
|
||||
if (desc.resource_type == WINED3D_RTYPE_TEXTURE)
|
||||
if (desc.resource_type == WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
IUnknown *parent = wined3d_resource_get_parent(resource);
|
||||
IDirect3DBaseTexture8 *texture;
|
||||
|
@ -950,7 +950,7 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
|
|||
device, width, height, format, flags, surface,
|
||||
usage, pool, multisample_type, multisample_quality);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = multisample_type;
|
||||
desc.multisample_quality = multisample_quality;
|
||||
|
|
|
@ -238,16 +238,38 @@ static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3
|
|||
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
|
||||
iface, adapter, device_type, adapter_format, usage, resource_type, format);
|
||||
|
||||
usage = usage & (WINED3DUSAGE_MASK | WINED3DUSAGE_QUERY_MASK);
|
||||
switch (resource_type)
|
||||
{
|
||||
case D3DRTYPE_SURFACE:
|
||||
wined3d_rtype = WINED3D_RTYPE_SURFACE;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VOLUME:
|
||||
wined3d_rtype = WINED3D_RTYPE_VOLUME;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_TEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VOLUMETEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_VOLUME_TEXTURE;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_CUBETEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VERTEXBUFFER:
|
||||
case D3DRTYPE_INDEXBUFFER:
|
||||
wined3d_rtype = WINED3D_RTYPE_BUFFER;
|
||||
break;
|
||||
|
||||
default:
|
||||
wined3d_rtype = resource_type;
|
||||
break;
|
||||
FIXME("Unhandled resource type %#x.\n", resource_type);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
|
|
|
@ -1157,7 +1157,7 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device,
|
|||
d3d8_resource_init(&texture->resource);
|
||||
list_init(&texture->rtv_list);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
|
@ -1202,12 +1202,12 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic
|
|||
d3d8_resource_init(&texture->resource);
|
||||
list_init(&texture->rtv_list);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
desc.usage = usage & WINED3DUSAGE_MASK;
|
||||
desc.usage |= WINED3DUSAGE_TEXTURE;
|
||||
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
|
||||
desc.pool = pool;
|
||||
desc.width = edge_length;
|
||||
desc.height = edge_length;
|
||||
|
|
|
@ -611,7 +611,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
|
|||
{
|
||||
struct d3d9_surface *surface;
|
||||
|
||||
if (desc.resource_type == WINED3D_RTYPE_TEXTURE)
|
||||
if (desc.resource_type == WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
IUnknown *parent = wined3d_resource_get_parent(resource);
|
||||
IDirect3DBaseTexture9 *texture;
|
||||
|
@ -1119,7 +1119,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
|
|||
device, width, height, format, flags, surface, usage, pool,
|
||||
multisample_type, multisample_quality);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = multisample_type;
|
||||
desc.multisample_quality = multisample_quality;
|
||||
|
|
|
@ -254,16 +254,38 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
|
|||
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
|
||||
iface, adapter, device_type, adapter_format, usage, resource_type, format);
|
||||
|
||||
usage = usage & (WINED3DUSAGE_MASK | WINED3DUSAGE_QUERY_MASK);
|
||||
switch (resource_type)
|
||||
{
|
||||
case D3DRTYPE_SURFACE:
|
||||
wined3d_rtype = WINED3D_RTYPE_SURFACE;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VOLUME:
|
||||
wined3d_rtype = WINED3D_RTYPE_VOLUME;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_TEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VOLUMETEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_VOLUME_TEXTURE;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_CUBETEXTURE:
|
||||
wined3d_rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
||||
break;
|
||||
|
||||
case D3DRTYPE_VERTEXBUFFER:
|
||||
case D3DRTYPE_INDEXBUFFER:
|
||||
wined3d_rtype = WINED3D_RTYPE_BUFFER;
|
||||
break;
|
||||
|
||||
default:
|
||||
wined3d_rtype = resource_type;
|
||||
break;
|
||||
FIXME("Unhandled resource type %#x.\n", resource_type);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
|
|
|
@ -1287,7 +1287,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
|
|||
d3d9_resource_init(&texture->resource);
|
||||
list_init(&texture->rtv_list);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
|
@ -1337,12 +1337,12 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
|
|||
d3d9_resource_init(&texture->resource);
|
||||
list_init(&texture->rtv_list);
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
desc.usage = usage & WINED3DUSAGE_MASK;
|
||||
desc.usage |= WINED3DUSAGE_TEXTURE;
|
||||
desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE;
|
||||
desc.pool = pool;
|
||||
desc.width = edge_length;
|
||||
desc.height = edge_length;
|
||||
|
|
|
@ -1091,7 +1091,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface,
|
|||
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
|
||||
{
|
||||
if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT, WINED3D_DEVICE_TYPE_HAL,
|
||||
mode.format_id, 0, WINED3D_RTYPE_TEXTURE, FormatList[i]) == D3D_OK)
|
||||
mode.format_id, 0, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
|
||||
{
|
||||
DDPIXELFORMAT pformat;
|
||||
|
||||
|
@ -1114,7 +1114,7 @@ static HRESULT d3d_device7_EnumTextureFormats(IDirect3DDevice7 *iface,
|
|||
{
|
||||
if (wined3d_check_device_format(device->ddraw->wined3d, WINED3DADAPTER_DEFAULT,
|
||||
WINED3D_DEVICE_TYPE_HAL, mode.format_id, WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
|
||||
WINED3D_RTYPE_TEXTURE, BumpFormatList[i]) == D3D_OK)
|
||||
WINED3D_RTYPE_TEXTURE_2D, BumpFormatList[i]) == D3D_OK)
|
||||
{
|
||||
DDPIXELFORMAT pformat;
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ static HRESULT WINAPI d3d_device2_EnumTextureFormats(IDirect3DDevice2 *iface,
|
|||
for (i = 0; i < sizeof(FormatList) / sizeof(*FormatList); ++i)
|
||||
{
|
||||
if (wined3d_check_device_format(device->ddraw->wined3d, 0, WINED3D_DEVICE_TYPE_HAL,
|
||||
mode.format_id, 0, WINED3D_RTYPE_TEXTURE, FormatList[i]) == D3D_OK)
|
||||
mode.format_id, 0, WINED3D_RTYPE_TEXTURE_2D, FormatList[i]) == D3D_OK)
|
||||
{
|
||||
DDSURFACEDESC sdesc;
|
||||
|
||||
|
|
|
@ -5660,8 +5660,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
|
|||
struct wined3d_display_mode mode;
|
||||
DDSURFACEDESC2 *desc, *mip_desc;
|
||||
struct ddraw_texture *texture;
|
||||
UINT layers, levels, i, j;
|
||||
unsigned int layers = 1;
|
||||
unsigned int pitch = 0;
|
||||
UINT levels, i, j;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p, version %u.\n",
|
||||
|
@ -5793,6 +5794,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
|
|||
ddrawformat_from_wined3dformat(&desc->u4.ddpfPixelFormat, mode.format_id);
|
||||
}
|
||||
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
wined3d_desc.format = wined3dformat_from_ddrawformat(&desc->u4.ddpfPixelFormat);
|
||||
if (wined3d_desc.format == WINED3DFMT_UNKNOWN)
|
||||
{
|
||||
|
@ -5908,9 +5910,12 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
|
|||
DWORD usage = 0;
|
||||
|
||||
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
||||
rtype = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||
{
|
||||
usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
||||
rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
}
|
||||
else if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
||||
rtype = WINED3D_RTYPE_TEXTURE;
|
||||
rtype = WINED3D_RTYPE_TEXTURE_2D;
|
||||
else
|
||||
rtype = WINED3D_RTYPE_SURFACE;
|
||||
|
||||
|
@ -6060,14 +6065,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
|
|||
|
||||
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
||||
{
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
|
||||
wined3d_desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP;
|
||||
layers = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
layers = 1;
|
||||
}
|
||||
|
||||
/* Some applications assume surfaces will always be mapped at the same
|
||||
* address. Some of those also assume that this address is valid even when
|
||||
|
|
|
@ -623,7 +623,7 @@ static void device_load_logo(struct wined3d_device *device, const char *filename
|
|||
bm.bmHeight = 32;
|
||||
}
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = WINED3DFMT_B5G6R5_UNORM;
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
|
@ -2016,7 +2016,7 @@ static void resolve_depth_buffer(struct wined3d_state *state)
|
|||
struct wined3d_texture *texture = state->textures[0];
|
||||
struct wined3d_surface *depth_stencil, *surface;
|
||||
|
||||
if (!texture || texture->resource.type != WINED3D_RTYPE_TEXTURE
|
||||
if (!texture || texture->resource.type != WINED3D_RTYPE_TEXTURE_2D
|
||||
|| !(texture->resource.format_flags & WINED3DFMT_FLAG_DEPTH))
|
||||
return;
|
||||
surface = surface_from_resource(texture->sub_resources[0]);
|
||||
|
@ -3586,8 +3586,9 @@ static HRESULT device_update_volume(struct wined3d_device *device,
|
|||
HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
|
||||
struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture)
|
||||
{
|
||||
unsigned int src_size, dst_size, src_skip_levels = 0;
|
||||
unsigned int layer_count, level_count, i, j;
|
||||
enum wined3d_resource_type type;
|
||||
unsigned int level_count, i, j, src_size, dst_size, src_skip_levels = 0;
|
||||
HRESULT hr;
|
||||
struct wined3d_context *context;
|
||||
|
||||
|
@ -3619,6 +3620,13 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
|
|||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
layer_count = src_texture->layer_count;
|
||||
if (layer_count != dst_texture->layer_count)
|
||||
{
|
||||
WARN("Source and destination have different layer counts.\n");
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
level_count = min(wined3d_texture_get_level_count(src_texture),
|
||||
wined3d_texture_get_level_count(dst_texture));
|
||||
|
||||
|
@ -3643,34 +3651,14 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
|
|||
/* Update every surface level of the texture. */
|
||||
switch (type)
|
||||
{
|
||||
case WINED3D_RTYPE_TEXTURE:
|
||||
case WINED3D_RTYPE_TEXTURE_2D:
|
||||
{
|
||||
unsigned int src_levels = src_texture->level_count;
|
||||
unsigned int dst_levels = dst_texture->level_count;
|
||||
struct wined3d_surface *src_surface;
|
||||
struct wined3d_surface *dst_surface;
|
||||
|
||||
for (i = 0; i < level_count; ++i)
|
||||
{
|
||||
src_surface = surface_from_resource(wined3d_texture_get_sub_resource(src_texture,
|
||||
i + src_skip_levels));
|
||||
dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture, i));
|
||||
hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to update surface, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WINED3D_RTYPE_CUBE_TEXTURE:
|
||||
{
|
||||
struct wined3d_surface *src_surface;
|
||||
struct wined3d_surface *dst_surface;
|
||||
unsigned int src_levels = wined3d_texture_get_level_count(src_texture);
|
||||
unsigned int dst_levels = wined3d_texture_get_level_count(dst_texture);
|
||||
|
||||
for (i = 0; i < 6; ++i)
|
||||
for (i = 0; i < layer_count; ++i)
|
||||
{
|
||||
for (j = 0; j < level_count; ++j)
|
||||
{
|
||||
|
@ -3678,8 +3666,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device,
|
|||
i * src_levels + j + src_skip_levels));
|
||||
dst_surface = surface_from_resource(wined3d_texture_get_sub_resource(dst_texture,
|
||||
i * dst_levels + j));
|
||||
hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr = wined3d_device_update_surface(device, src_surface, NULL, dst_surface, NULL)))
|
||||
{
|
||||
WARN("Failed to update surface, hr %#x.\n", hr);
|
||||
return hr;
|
||||
|
@ -3915,7 +3902,7 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device,
|
|||
return;
|
||||
}
|
||||
|
||||
if (dst_resource->type != WINED3D_RTYPE_TEXTURE)
|
||||
if (dst_resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(dst_resource->type));
|
||||
return;
|
||||
|
@ -3982,7 +3969,7 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
|
|||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (dst_resource->type != WINED3D_RTYPE_TEXTURE)
|
||||
if (dst_resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(dst_resource->type));
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
@ -4071,7 +4058,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
|
|||
return;
|
||||
}
|
||||
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE)
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
|
||||
return;
|
||||
|
@ -4144,7 +4131,7 @@ HRESULT CDECL wined3d_device_clear_rendertarget_view(struct wined3d_device *devi
|
|||
device, view, wine_dbgstr_rect(rect), color->r, color->g, color->b, color->a);
|
||||
|
||||
resource = view->resource;
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE && resource->type != WINED3D_RTYPE_CUBE_TEXTURE)
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
{
|
||||
FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type));
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
@ -4286,7 +4273,7 @@ static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined
|
|||
data.row_pitch = map_desc.row_pitch;
|
||||
data.slice_pitch = map_desc.slice_pitch;
|
||||
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = WINED3DFMT_B8G8R8A8_UNORM;
|
||||
desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
|
||||
desc.multisample_quality = 0;
|
||||
|
@ -4793,7 +4780,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
|
|||
|
||||
TRACE("Creating the depth stencil buffer\n");
|
||||
|
||||
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
texture_desc.format = swapchain->desc.auto_depth_stencil_format;
|
||||
texture_desc.multisample_type = swapchain->desc.multisample_type;
|
||||
texture_desc.multisample_quality = swapchain->desc.multisample_quality;
|
||||
|
@ -4983,8 +4970,7 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
|
|||
}
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_TEXTURE:
|
||||
case WINED3D_RTYPE_CUBE_TEXTURE:
|
||||
case WINED3D_RTYPE_TEXTURE_2D:
|
||||
case WINED3D_RTYPE_VOLUME_TEXTURE:
|
||||
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
|
||||
{
|
||||
|
|
|
@ -4619,21 +4619,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
|||
|
||||
switch (resource_type)
|
||||
{
|
||||
case WINED3D_RTYPE_CUBE_TEXTURE:
|
||||
format_flags |= WINED3DFMT_FLAG_TEXTURE;
|
||||
allowed_usage = WINED3DUSAGE_AUTOGENMIPMAP
|
||||
| WINED3DUSAGE_DYNAMIC
|
||||
| WINED3DUSAGE_RENDERTARGET
|
||||
| WINED3DUSAGE_SOFTWAREPROCESSING
|
||||
| WINED3DUSAGE_QUERY_FILTER
|
||||
| WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
|
||||
| WINED3DUSAGE_QUERY_SRGBREAD
|
||||
| WINED3DUSAGE_QUERY_SRGBWRITE
|
||||
| WINED3DUSAGE_QUERY_VERTEXTEXTURE
|
||||
| WINED3DUSAGE_QUERY_WRAPANDMIP;
|
||||
gl_type = WINED3D_GL_RES_TYPE_TEX_CUBE;
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_SURFACE:
|
||||
if (!CheckSurfaceCapability(adapter, adapter_format, format, wined3d->flags & WINED3D_NO3D))
|
||||
{
|
||||
|
@ -4647,19 +4632,12 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
|||
gl_type = WINED3D_GL_RES_TYPE_RB;
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_TEXTURE:
|
||||
if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
||||
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
|
||||
&& !gl_info->supported[ARB_SHADOW])
|
||||
{
|
||||
TRACE("[FAILED] - No shadow sampler support.\n");
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
|
||||
case WINED3D_RTYPE_TEXTURE_2D:
|
||||
format_flags |= WINED3DFMT_FLAG_TEXTURE;
|
||||
allowed_usage = WINED3DUSAGE_AUTOGENMIPMAP
|
||||
| WINED3DUSAGE_DEPTHSTENCIL
|
||||
| WINED3DUSAGE_DYNAMIC
|
||||
| WINED3DUSAGE_LEGACY_CUBEMAP
|
||||
| WINED3DUSAGE_RENDERTARGET
|
||||
| WINED3DUSAGE_SOFTWAREPROCESSING
|
||||
| WINED3DUSAGE_QUERY_FILTER
|
||||
|
@ -4670,6 +4648,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad
|
|||
| WINED3DUSAGE_QUERY_VERTEXTEXTURE
|
||||
| WINED3DUSAGE_QUERY_WRAPANDMIP;
|
||||
gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
|
||||
if (usage & WINED3DUSAGE_LEGACY_CUBEMAP)
|
||||
{
|
||||
allowed_usage &= ~(WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_QUERY_LEGACYBUMPMAP);
|
||||
gl_type = WINED3D_GL_RES_TYPE_TEX_CUBE;
|
||||
}
|
||||
else if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
||||
&& (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_SHADOW)
|
||||
&& !gl_info->supported[ARB_SHADOW])
|
||||
{
|
||||
TRACE("[FAILED] - No shadow sampler support.\n");
|
||||
return WINED3DERR_NOTAVAILABLE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_VOLUME_TEXTURE:
|
||||
|
|
|
@ -57,6 +57,7 @@ static void resource_check_usage(DWORD usage)
|
|||
| WINED3DUSAGE_AUTOGENMIPMAP
|
||||
| WINED3DUSAGE_STATICDECL
|
||||
| WINED3DUSAGE_OVERLAY
|
||||
| WINED3DUSAGE_LEGACY_CUBEMAP
|
||||
| WINED3DUSAGE_TEXTURE;
|
||||
|
||||
/* WINED3DUSAGE_WRITEONLY is supposed to result in write-combined mappings
|
||||
|
@ -78,84 +79,93 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
|||
void *parent, const struct wined3d_parent_ops *parent_ops,
|
||||
const struct wined3d_resource_ops *resource_ops)
|
||||
{
|
||||
const struct wined3d *d3d = device->wined3d;
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
static const enum wined3d_gl_resource_type gl_resource_types[][4] =
|
||||
{
|
||||
/* 0 */ {WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_SURFACE */ {WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_VOLUME */ {WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_TEXTURE */ {WINED3D_GL_RES_TYPE_TEX_2D,
|
||||
WINED3D_GL_RES_TYPE_TEX_RECT, WINED3D_GL_RES_TYPE_RB, WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_VOLUME_TEXTURE */ {WINED3D_GL_RES_TYPE_TEX_3D, WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_CUBE_TEXTURE */ {WINED3D_GL_RES_TYPE_TEX_CUBE, WINED3D_GL_RES_TYPE_COUNT},
|
||||
/* WINED3D_RTYPE_BUFFER */ {WINED3D_GL_RES_TYPE_BUFFER, WINED3D_GL_RES_TYPE_COUNT},
|
||||
};
|
||||
enum wined3d_gl_resource_type base_type = WINED3D_GL_RES_TYPE_COUNT;
|
||||
enum wined3d_gl_resource_type gl_type = WINED3D_GL_RES_TYPE_COUNT;
|
||||
enum wined3d_gl_resource_type base_type = gl_resource_types[type][0];
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
BOOL tex_2d_ok = FALSE;
|
||||
unsigned int i;
|
||||
|
||||
static const struct
|
||||
{
|
||||
enum wined3d_resource_type type;
|
||||
DWORD cube_usage;
|
||||
enum wined3d_gl_resource_type gl_type;
|
||||
}
|
||||
resource_types[] =
|
||||
{
|
||||
{WINED3D_RTYPE_BUFFER, 0, WINED3D_GL_RES_TYPE_BUFFER},
|
||||
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_2D},
|
||||
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_RECT},
|
||||
{WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_RB},
|
||||
{WINED3D_RTYPE_TEXTURE_2D, WINED3DUSAGE_LEGACY_CUBEMAP, WINED3D_GL_RES_TYPE_TEX_CUBE},
|
||||
{WINED3D_RTYPE_VOLUME_TEXTURE, 0, WINED3D_GL_RES_TYPE_TEX_3D},
|
||||
};
|
||||
|
||||
resource_check_usage(usage);
|
||||
|
||||
if (base_type != WINED3D_GL_RES_TYPE_COUNT)
|
||||
for (i = 0; i < ARRAY_SIZE(resource_types); ++i)
|
||||
{
|
||||
unsigned int i;
|
||||
BOOL tex_2d_ok = FALSE;
|
||||
if (resource_types[i].type != type
|
||||
|| resource_types[i].cube_usage != (usage & WINED3DUSAGE_LEGACY_CUBEMAP))
|
||||
continue;
|
||||
|
||||
for (i = 0; (gl_type = gl_resource_types[type][i]) != WINED3D_GL_RES_TYPE_COUNT; i++)
|
||||
gl_type = resource_types[i].gl_type;
|
||||
if (base_type == WINED3D_GL_RES_TYPE_COUNT)
|
||||
base_type = gl_type;
|
||||
|
||||
if ((usage & WINED3DUSAGE_RENDERTARGET) && !(format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
|
||||
{
|
||||
if ((usage & WINED3DUSAGE_RENDERTARGET) && !(format->flags[gl_type] & WINED3DFMT_FLAG_RENDERTARGET))
|
||||
{
|
||||
WARN("Format %s cannot be used for render targets.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
if ((usage & WINED3DUSAGE_DEPTHSTENCIL) &&
|
||||
!(format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
|
||||
{
|
||||
WARN("Format %s cannot be used for depth/stencil buffers.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
|
||||
&& usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)
|
||||
&& !(format->flags[gl_type] & WINED3DFMT_FLAG_FBO_ATTACHABLE))
|
||||
{
|
||||
WARN("Render target or depth stencil is not FBO attachable.\n");
|
||||
continue;
|
||||
}
|
||||
if ((usage & WINED3DUSAGE_TEXTURE) && !(format->flags[gl_type] & WINED3DFMT_FLAG_TEXTURE))
|
||||
{
|
||||
WARN("Format %s cannot be used for texturing.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
if (((width & (width - 1)) || (height & (height - 1)))
|
||||
&& !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
|
||||
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]
|
||||
&& gl_type == WINED3D_GL_RES_TYPE_TEX_2D)
|
||||
{
|
||||
TRACE("Skipping 2D texture type to try texture rectangle.\n");
|
||||
tex_2d_ok = TRUE;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
WARN("Format %s cannot be used for render targets.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gl_type == WINED3D_GL_RES_TYPE_COUNT)
|
||||
if ((usage & WINED3DUSAGE_DEPTHSTENCIL)
|
||||
&& !(format->flags[gl_type] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
|
||||
{
|
||||
if (tex_2d_ok)
|
||||
{
|
||||
/* Non power of 2 texture and rectangle textures or renderbuffers do not work.
|
||||
* Use 2D textures, the texture code will pad to a power of 2 size. */
|
||||
gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
|
||||
}
|
||||
else if (pool == WINED3D_POOL_SCRATCH)
|
||||
{
|
||||
/* Needed for proper format information. */
|
||||
gl_type = base_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Did not find a suitable GL resource type, resource type, d3d type %u.\n", type);
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
WARN("Format %s cannot be used for depth/stencil buffers.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
|
||||
&& usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)
|
||||
&& !(format->flags[gl_type] & WINED3DFMT_FLAG_FBO_ATTACHABLE))
|
||||
{
|
||||
WARN("Render target or depth stencil is not FBO attachable.\n");
|
||||
continue;
|
||||
}
|
||||
if ((usage & WINED3DUSAGE_TEXTURE) && !(format->flags[gl_type] & WINED3DFMT_FLAG_TEXTURE))
|
||||
{
|
||||
WARN("Format %s cannot be used for texturing.\n", debug_d3dformat(format->id));
|
||||
continue;
|
||||
}
|
||||
if (((width & (width - 1)) || (height & (height - 1)))
|
||||
&& !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
|
||||
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]
|
||||
&& gl_type == WINED3D_GL_RES_TYPE_TEX_2D)
|
||||
{
|
||||
TRACE("Skipping 2D texture type to try texture rectangle.\n");
|
||||
tex_2d_ok = TRUE;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (base_type != WINED3D_GL_RES_TYPE_COUNT && i == ARRAY_SIZE(resource_types))
|
||||
{
|
||||
if (tex_2d_ok)
|
||||
{
|
||||
/* Non power of 2 texture and rectangle textures or renderbuffers do not work.
|
||||
* Use 2D textures, the texture code will pad to a power of 2 size. */
|
||||
gl_type = WINED3D_GL_RES_TYPE_TEX_2D;
|
||||
}
|
||||
else if (pool == WINED3D_POOL_SCRATCH)
|
||||
{
|
||||
/* Needed for proper format information. */
|
||||
gl_type = base_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Did not find a suitable GL resource type for resource type %s.\n",
|
||||
debug_d3dresourcetype(type));
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +217,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
|||
}
|
||||
|
||||
/* Check that we have enough video ram left */
|
||||
if (pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
|
||||
if (pool == WINED3D_POOL_DEFAULT && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
|
||||
{
|
||||
if (size > wined3d_device_get_available_texture_mem(device))
|
||||
{
|
||||
|
@ -402,8 +412,8 @@ BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource)
|
|||
{
|
||||
struct wined3d_swapchain *swapchain;
|
||||
|
||||
/* Only texture resources can be onscreen. */
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE)
|
||||
/* Only 2D texture resources can be onscreen. */
|
||||
if (resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
return TRUE;
|
||||
|
||||
/* Not on a swapchain - must be offscreen */
|
||||
|
|
|
@ -2340,7 +2340,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_surface *so
|
|||
|
||||
/* FIXME: Multisampled conversion? */
|
||||
wined3d_resource_get_desc(&source->resource, &desc);
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
desc.format = to_fmt;
|
||||
desc.usage = 0;
|
||||
desc.pool = WINED3D_POOL_SCRATCH;
|
||||
|
|
|
@ -821,7 +821,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
|
|||
|
||||
TRACE("Creating front buffer.\n");
|
||||
|
||||
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
texture_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
|
||||
texture_desc.format = swapchain->desc.backbuffer_format;
|
||||
texture_desc.multisample_type = swapchain->desc.multisample_type;
|
||||
texture_desc.multisample_quality = swapchain->desc.multisample_quality;
|
||||
|
|
|
@ -1450,18 +1450,17 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
|
|||
|
||||
switch (desc->resource_type)
|
||||
{
|
||||
case WINED3D_RTYPE_TEXTURE:
|
||||
hr = texture_init(object, desc, level_count, surface_flags, device, parent, parent_ops);
|
||||
case WINED3D_RTYPE_TEXTURE_2D:
|
||||
if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
|
||||
hr = cubetexture_init(object, desc, level_count, surface_flags, device, parent, parent_ops);
|
||||
else
|
||||
hr = texture_init(object, desc, level_count, surface_flags, device, parent, parent_ops);
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_VOLUME_TEXTURE:
|
||||
hr = volumetexture_init(object, desc, level_count, device, parent, parent_ops);
|
||||
break;
|
||||
|
||||
case WINED3D_RTYPE_CUBE_TEXTURE:
|
||||
hr = cubetexture_init(object, desc, level_count, surface_flags, device, parent, parent_ops);
|
||||
break;
|
||||
|
||||
default:
|
||||
ERR("Invalid resource type %s.\n", debug_d3dresourcetype(desc->resource_type));
|
||||
hr = WINED3DERR_INVALIDCALL;
|
||||
|
|
|
@ -3202,14 +3202,13 @@ const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type)
|
|||
{
|
||||
switch (resource_type)
|
||||
{
|
||||
#define RES_TO_STR(res) case res: return #res
|
||||
RES_TO_STR(WINED3D_RTYPE_SURFACE);
|
||||
RES_TO_STR(WINED3D_RTYPE_VOLUME);
|
||||
RES_TO_STR(WINED3D_RTYPE_TEXTURE);
|
||||
RES_TO_STR(WINED3D_RTYPE_VOLUME_TEXTURE);
|
||||
RES_TO_STR(WINED3D_RTYPE_CUBE_TEXTURE);
|
||||
RES_TO_STR(WINED3D_RTYPE_BUFFER);
|
||||
#undef RES_TO_STR
|
||||
#define WINED3D_TO_STR(x) case x: return #x
|
||||
WINED3D_TO_STR(WINED3D_RTYPE_SURFACE);
|
||||
WINED3D_TO_STR(WINED3D_RTYPE_VOLUME);
|
||||
WINED3D_TO_STR(WINED3D_RTYPE_VOLUME_TEXTURE);
|
||||
WINED3D_TO_STR(WINED3D_RTYPE_BUFFER);
|
||||
WINED3D_TO_STR(WINED3D_RTYPE_TEXTURE_2D);
|
||||
#undef WINED3D_TO_STR
|
||||
default:
|
||||
FIXME("Unrecognized resource type %#x.\n", resource_type);
|
||||
return "unrecognized";
|
||||
|
|
|
@ -2796,10 +2796,7 @@ static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
|
|||
struct wined3d_resource *resource;
|
||||
struct wined3d_texture *texture;
|
||||
|
||||
if (!view)
|
||||
return NULL;
|
||||
|
||||
if (view->resource->type != WINED3D_RTYPE_TEXTURE && view->resource->type != WINED3D_RTYPE_CUBE_TEXTURE)
|
||||
if (!view || view->resource->type != WINED3D_RTYPE_TEXTURE_2D)
|
||||
return NULL;
|
||||
|
||||
texture = wined3d_texture_from_resource(view->resource);
|
||||
|
|
|
@ -657,10 +657,9 @@ enum wined3d_resource_type
|
|||
{
|
||||
WINED3D_RTYPE_SURFACE = 1,
|
||||
WINED3D_RTYPE_VOLUME = 2,
|
||||
WINED3D_RTYPE_TEXTURE = 3,
|
||||
WINED3D_RTYPE_VOLUME_TEXTURE = 4,
|
||||
WINED3D_RTYPE_CUBE_TEXTURE = 5,
|
||||
WINED3D_RTYPE_BUFFER = 6,
|
||||
WINED3D_RTYPE_VOLUME_TEXTURE = 3,
|
||||
WINED3D_RTYPE_BUFFER = 4,
|
||||
WINED3D_RTYPE_TEXTURE_2D = 5,
|
||||
};
|
||||
|
||||
enum wined3d_pool
|
||||
|
@ -821,6 +820,8 @@ enum wined3d_display_rotation
|
|||
#define WINED3DUSAGE_DMAP 0x00004000
|
||||
#define WINED3DUSAGE_TEXTAPI 0x10000000
|
||||
#define WINED3DUSAGE_MASK 0x10007fff
|
||||
|
||||
#define WINED3DUSAGE_LEGACY_CUBEMAP 0x00800000
|
||||
#define WINED3DUSAGE_TEXTURE 0x01000000
|
||||
#define WINED3DUSAGE_OWNDC 0x02000000
|
||||
#define WINED3DUSAGE_STATICDECL 0x04000000
|
||||
|
|
Loading…
Reference in a new issue