diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index f03cd11ba..ec455f937 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<DxvkSampler> 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 9979848f8..30bab91bc 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -556,6 +556,7 @@ namespace dxvk { Rc<DxvkDevice> m_device; Rc<DxvkContext> m_context; + Rc<DxvkSampler> m_defaultSampler; Com<D3D11BlendState> m_defaultBlendState; Com<D3D11DepthStencilState> m_defaultDepthStencilState; @@ -595,6 +596,8 @@ namespace dxvk { void ApplyViewportState(); + Rc<DxvkSampler> CreateDefaultSampler(); + }; }