libs/vkd3d: Introduce d3d12_resource_is_texture() helper function.

Makes some code easier to read.
This commit is contained in:
Józef Kucia 2017-08-30 18:31:52 +02:00
parent f1aa742569
commit 904858f4a9
3 changed files with 15 additions and 9 deletions

View File

@ -1205,7 +1205,7 @@ static void d3d12_command_list_transition_resource_to_initial_state(struct d3d12
const struct vkd3d_format *format;
VkImageMemoryBarrier barrier;
assert(!d3d12_resource_is_buffer(resource));
assert(d3d12_resource_is_texture(resource));
if (!(format = vkd3d_format_from_d3d12_resource_desc(&resource->desc, 0)))
{
@ -1864,7 +1864,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
&& dst->Type == D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT)
{
assert(d3d12_resource_is_buffer(dst_resource));
assert(!d3d12_resource_is_buffer(src_resource));
assert(d3d12_resource_is_texture(src_resource));
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&src_resource->desc,
dst->u.PlacedFootprint.Footprint.Format)))
@ -1886,7 +1886,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
else if (src->Type == D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT
&& dst->Type == D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX)
{
assert(!d3d12_resource_is_buffer(dst_resource));
assert(d3d12_resource_is_texture(dst_resource));
assert(d3d12_resource_is_buffer(src_resource));
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc,
@ -1909,8 +1909,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(ID3D12Graphic
else if (src->Type == D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX
&& dst->Type == D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX)
{
assert(!d3d12_resource_is_buffer(dst_resource));
assert(!d3d12_resource_is_buffer(src_resource));
assert(d3d12_resource_is_texture(dst_resource));
assert(d3d12_resource_is_texture(src_resource));
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
{

View File

@ -461,7 +461,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_Map(ID3D12Resource *iface, UINT
return E_INVALIDARG;
}
if (!d3d12_resource_is_buffer(resource))
if (d3d12_resource_is_texture(resource))
{
/* Textures seem to be mappable only on UMA adapters. */
FIXME("Not implemented for textures.\n");
@ -505,7 +505,7 @@ static void STDMETHODCALLTYPE d3d12_resource_Unmap(ID3D12Resource *iface, UINT s
device = resource->device;
vk_procs = &device->vk_procs;
if (!d3d12_resource_is_buffer(resource))
if (d3d12_resource_is_texture(resource))
{
FIXME("Not implemented for textures.\n");
return;
@ -628,8 +628,9 @@ static HRESULT d3d12_committed_resource_init(struct d3d12_resource *resource, st
resource->desc = *desc;
if (!d3d12_resource_is_buffer(resource)
&& (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD || heap_properties->Type == D3D12_HEAP_TYPE_READBACK))
if (d3d12_resource_is_texture(resource)
&& (heap_properties->Type == D3D12_HEAP_TYPE_UPLOAD
|| heap_properties->Type == D3D12_HEAP_TYPE_READBACK))
{
WARN("Texture cannot be created on a UPLOAD/READBACK heap.\n");
return E_INVALIDARG;

View File

@ -176,6 +176,11 @@ static inline bool d3d12_resource_is_buffer(const struct d3d12_resource *resourc
return resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER;
}
static inline bool d3d12_resource_is_texture(const struct d3d12_resource *resource)
{
return resource->desc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER;
}
HRESULT d3d12_committed_resource_create(struct d3d12_device *device,
const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags,
const D3D12_RESOURCE_DESC *desc, D3D12_RESOURCE_STATES initial_state,