From 1b67ffaed2d5d823589205d99f18da44aa2059be Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 10 Jan 2018 19:07:55 +0100 Subject: [PATCH] [d3d11] Added default sampler state --- src/d3d11/d3d11_context.cpp | 27 ++++++++++++++++++++++++++- src/d3d11/d3d11_context.h | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index f03cd11b..ec455f93 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -41,6 +41,10 @@ namespace dxvk { m_context->setBlendConstants(m_state.om.blendFactor); m_context->setStencilReference(m_state.om.stencilRef); + + // Create a default sampler that we're going to bind + // when the application binds null to a sampler slot. + m_defaultSampler = CreateDefaultSampler(); } @@ -1853,7 +1857,7 @@ namespace dxvk { slotId + i, sampler->GetDXVKSampler()); } else { m_context->bindResourceSampler( - slotId + i, nullptr); + slotId + i, m_defaultSampler); } } } @@ -1992,4 +1996,25 @@ namespace dxvk { scissors.data()); } + + Rc D3D11DeviceContext::CreateDefaultSampler() { + DxvkSamplerCreateInfo info; + info.minFilter = VK_FILTER_LINEAR; + info.magFilter = VK_FILTER_LINEAR; + info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; + info.mipmapLodBias = 0.0f; + info.mipmapLodMin = -256.0f; + info.mipmapLodMax = 256.0f; + info.useAnisotropy = VK_FALSE; + info.maxAnisotropy = 1.0f; + info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + info.compareToDepth = VK_FALSE; + info.compareOp = VK_COMPARE_OP_NEVER; + info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; + info.usePixelCoord = VK_FALSE; + return m_device->createSampler(info); + } + } diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 9979848f..30bab91b 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -556,6 +556,7 @@ namespace dxvk { Rc m_device; Rc m_context; + Rc m_defaultSampler; Com m_defaultBlendState; Com m_defaultDepthStencilState; @@ -595,6 +596,8 @@ namespace dxvk { void ApplyViewportState(); + Rc CreateDefaultSampler(); + }; }