From ff219c6035b14e41c4a60b67455c850b780637e6 Mon Sep 17 00:00:00 2001 From: vlj Date: Mon, 29 Jun 2015 19:40:22 +0200 Subject: [PATCH] d3d12: Factorise sampler desc creation in a separate function --- rpcs3/Emu/RSX/D3D12/D3D12GSRender.h | 2 -- rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp | 34 ++++++++++++++++------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index 62532cc876..ef84d059f8 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -400,8 +400,6 @@ private: * returns the number of texture uploaded */ size_t UploadTextures(); - size_t GetMaxAniso(size_t aniso); - D3D12_TEXTURE_ADDRESS_MODE GetWrap(size_t wrap); void PrepareRenderTargets(); protected: diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index 4cf68fb251..53f2952b79 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -80,12 +80,9 @@ D3D12_TEXTURE_ADDRESS_MODE getSamplerWrap(size_t wrap) case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; } - return D3D12_TEXTURE_ADDRESS_MODE_WRAP; } - - static D3D12_FILTER getSamplerFilter(u32 minFilter, u32 magFilter) { @@ -136,6 +133,23 @@ D3D12_FILTER getSamplerFilter(u32 minFilter, u32 magFilter) return D3D12_ENCODE_BASIC_FILTER(min, mag, mip, D3D12_FILTER_REDUCTION_TYPE_STANDARD); } +static +D3D12_SAMPLER_DESC getSamplerDesc(const RSXTexture &texture) +{ + D3D12_SAMPLER_DESC samplerDesc = {}; + samplerDesc.Filter = getSamplerFilter(texture.GetMinFilter(), texture.GetMagFilter()); + samplerDesc.AddressU = getSamplerWrap(texture.GetWrapS()); + samplerDesc.AddressV = getSamplerWrap(texture.GetWrapT()); + samplerDesc.AddressW = getSamplerWrap(texture.GetWrapR()); + samplerDesc.ComparisonFunc = getSamplerCompFunc[texture.GetZfunc()]; + samplerDesc.MaxAnisotropy = (UINT)getSamplerMaxAniso(texture.GetMaxAniso()); + samplerDesc.MipLODBias = texture.GetBias(); + samplerDesc.BorderColor[4] = (FLOAT)texture.GetBorderColor(); + samplerDesc.MinLOD = (FLOAT)(texture.GetMinLOD() >> 8); + samplerDesc.MaxLOD = (FLOAT)(texture.GetMaxLOD() >> 8); + return samplerDesc; +} + struct MipmapLevelInfo { size_t offset; @@ -866,20 +880,10 @@ size_t D3D12GSRender::UploadTextures() Handle.ptr += (getCurrentResourceStorage().m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); m_device->CreateShaderResourceView(vramTexture, &srvDesc, Handle); - D3D12_SAMPLER_DESC samplerDesc = {}; - samplerDesc.Filter = getSamplerFilter(m_textures[i].GetMinFilter(), m_textures[i].GetMagFilter()); - samplerDesc.AddressU = getSamplerWrap(m_textures[i].GetWrapS()); - samplerDesc.AddressV = getSamplerWrap(m_textures[i].GetWrapT()); - samplerDesc.AddressW = getSamplerWrap(m_textures[i].GetWrapR()); - samplerDesc.ComparisonFunc = getSamplerCompFunc[m_textures[i].GetZfunc()]; - samplerDesc.MaxAnisotropy = (UINT)getSamplerMaxAniso(m_textures[i].GetMaxAniso()); - samplerDesc.MipLODBias = m_textures[i].GetBias(); - samplerDesc.BorderColor[4] = (FLOAT)m_textures[i].GetBorderColor(); - samplerDesc.MinLOD = (FLOAT)(m_textures[i].GetMinLOD() >> 8); - samplerDesc.MaxLOD = (FLOAT)(m_textures[i].GetMaxLOD() >> 8); + Handle = getCurrentResourceStorage().m_samplerDescriptorHeap->GetCPUDescriptorHandleForHeapStart(); Handle.ptr += (getCurrentResourceStorage().m_currentTextureIndex + usedTexture) * m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - m_device->CreateSampler(&samplerDesc, Handle); + m_device->CreateSampler(&getSamplerDesc(m_textures[i]), Handle); usedTexture++; }