+#define create_default_texture2dms(a, b, c, d, e, f, g, h) create_default_texture2dms_(__LINE__, a, b, c, d, e, f, g, h) +static inline ID3D12Resource *create_default_texture2dms_(unsigned int line, ID3D12Device *device, + unsigned int width, unsigned int height, unsigned int array_size, unsigned int sample_count, + DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES initial_state) +{ + return create_default_texture_(line, device, D3D12_RESOURCE_DIMENSION_TEXTURE2D, width, height, array_size, 1, + format, sample_count, flags | D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, initial_state); }
It doesn't seem ideal to swap the order of "format" and "sample_count" between create_default_texture_() and create_default_texture2dms_(). Also, why are we adding D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET here?
+[srv 0] +% r32g32b32a32 is not necessarily supported with 4x MSAA. +format r32 float +size (2dms, 4, 2, 2) +% Data upload is not supported.
Sure, but I don't think data upload is needed here either.
+% 4.1 supports GetRenderTargetSamplePosition/Count but not UAVs, and returning +% results in the RTV brings complications in D3D11.
Which complications would those be?
- resource->resource = create_default_texture2d(device, params->width, params->height, 1, params->level_count, - params->format, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_STATE_RENDER_TARGET); + if (params->sample_count) + { + if (params->level_count > 1) + fatal_error("Multisample resource has multiple levels.\n"); + resource->resource = create_default_texture2dms(device, params->width, params->height, 1, params->sample_count, + params->format, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_STATE_RENDER_TARGET); + } + else + { + resource->resource = create_default_texture2d(device, params->width, params->height, 1, params->level_count, + params->format, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_STATE_RENDER_TARGET); + }
It seems tempting to just use create_default_texture_().