[D3D12] d3d12_break_on_error + fix PerformSwap descriptor heap wrap

This commit is contained in:
Triang3l
2020-05-17 00:26:04 +03:00
parent 8341a48210
commit b7a5c24bb1
7 changed files with 88 additions and 34 deletions

View File

@@ -2011,8 +2011,8 @@ void TextureCache::CreateScaledResolveBufferRawUAV(
first_unscaled_4kb_page << 14);
}
bool TextureCache::RequestSwapTexture(D3D12_CPU_DESCRIPTOR_HANDLE handle,
TextureFormat& format_out) {
ID3D12Resource* TextureCache::RequestSwapTexture(
D3D12_SHADER_RESOURCE_VIEW_DESC& srv_desc_out, TextureFormat& format_out) {
auto& regs = *register_file_;
const auto& fetch = regs.Get<xenos::xe_gpu_texture_fetch_t>(
XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0);
@@ -2020,11 +2020,11 @@ bool TextureCache::RequestSwapTexture(D3D12_CPU_DESCRIPTOR_HANDLE handle,
uint32_t swizzle;
BindingInfoFromFetchConstant(fetch, key, &swizzle, nullptr, nullptr);
if (key.base_page == 0 || key.dimension != Dimension::k2D) {
return false;
return nullptr;
}
Texture* texture = FindOrCreateTexture(key);
if (texture == nullptr || !LoadTextureData(texture)) {
return false;
return nullptr;
}
MarkTextureUsed(texture);
// The swap texture is likely to be used only for the presentation pixel
@@ -2034,21 +2034,17 @@ bool TextureCache::RequestSwapTexture(D3D12_CPU_DESCRIPTOR_HANDLE handle,
texture->resource, texture->state,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
texture->state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc;
srv_desc.Format = GetDXGIUnormFormat(key);
srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srv_desc.Shader4ComponentMapping =
srv_desc_out.Format = GetDXGIUnormFormat(key);
srv_desc_out.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
srv_desc_out.Shader4ComponentMapping =
swizzle |
D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES;
srv_desc.Texture2D.MostDetailedMip = 0;
srv_desc.Texture2D.MipLevels = 1;
srv_desc.Texture2D.PlaneSlice = 0;
srv_desc.Texture2D.ResourceMinLODClamp = 0.0f;
auto device =
command_processor_->GetD3D12Context()->GetD3D12Provider()->GetDevice();
device->CreateShaderResourceView(texture->resource, &srv_desc, handle);
srv_desc_out.Texture2D.MostDetailedMip = 0;
srv_desc_out.Texture2D.MipLevels = 1;
srv_desc_out.Texture2D.PlaneSlice = 0;
srv_desc_out.Texture2D.ResourceMinLODClamp = 0.0f;
format_out = key.format;
return true;
return texture->resource;
}
bool TextureCache::IsDecompressionNeeded(TextureFormat format, uint32_t width,