Revert "[d3d11] Added dummy resoruce binding for buffers"

This approach will not work if the d3d11 context binds an
incompatible resouce in case the pipeline itself changes.
This commit is contained in:
Philip Rebohle 2018-01-08 13:01:31 +01:00
parent 24ad9e730c
commit ad10ab07f8
7 changed files with 11 additions and 125 deletions

View File

@ -10,17 +10,13 @@
namespace dxvk { namespace dxvk {
D3D11DeviceContext::D3D11DeviceContext( D3D11DeviceContext::D3D11DeviceContext(
D3D11Device* parent, D3D11Device* parent,
const Rc<DxvkDevice>& device, Rc<DxvkDevice> device)
const Rc<D3D11DummyResources>& dummyResources) : m_parent(parent),
: m_parent(parent), m_device(device), m_device(device) {
m_dummyResources(dummyResources) {
// Create and initialize underlying context so that the
// application can use it for rendering immediately
m_context = m_device->createContext(); m_context = m_device->createContext();
m_context->beginRecording( m_context->beginRecording(
m_device->createCommandList()); m_device->createCommandList());
// Create default state objects. We won't ever return them // Create default state objects. We won't ever return them
// to the application, but we'll use them to apply state. // to the application, but we'll use them to apply state.
Com<ID3D11BlendState> defaultBlendState; Com<ID3D11BlendState> defaultBlendState;
@ -1812,7 +1808,7 @@ namespace dxvk {
slotId + i, newBuffer->GetBufferSlice(0)); slotId + i, newBuffer->GetBufferSlice(0));
} else { } else {
m_context->bindResourceBuffer( m_context->bindResourceBuffer(
slotId + i, DxvkBufferSlice(m_dummyResources->buffer)); slotId + i, DxvkBufferSlice());
} }
} }
} }
@ -1840,7 +1836,7 @@ namespace dxvk {
slotId + i, sampler->GetDXVKSampler()); slotId + i, sampler->GetDXVKSampler());
} else { } else {
m_context->bindResourceSampler( m_context->bindResourceSampler(
slotId + i, m_dummyResources->sampler); slotId + i, nullptr);
} }
} }
} }

View File

@ -4,7 +4,6 @@
#include "../dxvk/dxvk_device.h" #include "../dxvk/dxvk_device.h"
#include "d3d11_context_state.h" #include "d3d11_context_state.h"
#include "d3d11_dummy_resource.h"
#include "d3d11_device_child.h" #include "d3d11_device_child.h"
#include "d3d11_view.h" #include "d3d11_view.h"
@ -17,9 +16,8 @@ namespace dxvk {
public: public:
D3D11DeviceContext( D3D11DeviceContext(
D3D11Device* parent, D3D11Device* parent,
const Rc<DxvkDevice>& device, Rc<DxvkDevice> device);
const Rc<D3D11DummyResources>& dummyResources);
~D3D11DeviceContext(); ~D3D11DeviceContext();
ULONG STDMETHODCALLTYPE AddRef() final; ULONG STDMETHODCALLTYPE AddRef() final;
@ -556,10 +554,8 @@ namespace dxvk {
const D3D11_DEVICE_CONTEXT_TYPE m_type = D3D11_DEVICE_CONTEXT_IMMEDIATE; const D3D11_DEVICE_CONTEXT_TYPE m_type = D3D11_DEVICE_CONTEXT_IMMEDIATE;
const UINT m_flags = 0; const UINT m_flags = 0;
Rc<DxvkDevice> m_device; Rc<DxvkDevice> m_device;
Rc<DxvkContext> m_context; Rc<DxvkContext> m_context;
Rc<D3D11DummyResources> m_dummyResources;
Com<D3D11BlendState> m_defaultBlendState; Com<D3D11BlendState> m_defaultBlendState;
Com<D3D11DepthStencilState> m_defaultDepthStencilState; Com<D3D11DepthStencilState> m_defaultDepthStencilState;

View File

@ -24,8 +24,6 @@ namespace dxvk {
m_featureFlags (featureFlags), m_featureFlags (featureFlags),
m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()), m_dxvkDevice (m_dxgiDevice->GetDXVKDevice()),
m_dxvkAdapter (m_dxvkDevice->adapter()), m_dxvkAdapter (m_dxvkDevice->adapter()),
m_dummyResources(new D3D11DummyResources(
m_dxvkDevice, GetEnabledShaderStages())),
m_dxbcOptions (m_dxvkDevice) { m_dxbcOptions (m_dxvkDevice) {
Com<IDXGIAdapter> adapter; Com<IDXGIAdapter> adapter;
@ -37,7 +35,7 @@ namespace dxvk {
m_dxgiDevice->SetDeviceLayer(this); m_dxgiDevice->SetDeviceLayer(this);
m_presentDevice->SetDeviceLayer(this); m_presentDevice->SetDeviceLayer(this);
m_context = new D3D11DeviceContext(this, m_dxvkDevice, m_dummyResources); m_context = new D3D11DeviceContext(this, m_dxvkDevice);
m_resourceInitContext = m_dxvkDevice->createContext(); m_resourceInitContext = m_dxvkDevice->createContext();
} }

View File

@ -6,7 +6,6 @@
#include "../util/com/com_private_data.h" #include "../util/com/com_private_data.h"
#include "d3d11_dummy_resource.h"
#include "d3d11_interfaces.h" #include "d3d11_interfaces.h"
#include "d3d11_state.h" #include "d3d11_state.h"
#include "d3d11_util.h" #include "d3d11_util.h"
@ -257,7 +256,6 @@ namespace dxvk {
const Rc<DxvkDevice> m_dxvkDevice; const Rc<DxvkDevice> m_dxvkDevice;
const Rc<DxvkAdapter> m_dxvkAdapter; const Rc<DxvkAdapter> m_dxvkAdapter;
const Rc<D3D11DummyResources> m_dummyResources;
const DxbcOptions m_dxbcOptions; const DxbcOptions m_dxbcOptions;

View File

@ -1,64 +0,0 @@
#include "d3d11_dummy_resource.h"
namespace dxvk {
D3D11DummyResources::D3D11DummyResources(
const Rc<DxvkDevice>& device,
VkPipelineStageFlags enabledShaderStages) {
// Create a sampler to use with dummy textures. Parameters
// are the same as the default D3D11 sampling parameters.
DxvkSamplerCreateInfo samplerInfo;
samplerInfo.magFilter = VK_FILTER_LINEAR;
samplerInfo.minFilter = VK_FILTER_LINEAR;
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerInfo.mipmapLodBias = 0.0f;
samplerInfo.mipmapLodMin = 0.0f;
samplerInfo.mipmapLodMax = 256.0f;
samplerInfo.useAnisotropy = VK_FALSE;
samplerInfo.maxAnisotropy = 1.0f;
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
samplerInfo.compareToDepth = VK_FALSE;
samplerInfo.compareOp = VK_COMPARE_OP_NEVER;
samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
samplerInfo.usePixelCoord = VK_FALSE;
this->sampler = device->createSampler(samplerInfo);
// Create a dummy buffer. We'll use this for both texel buffers
// and uniform buffers. The contents will be initialized to zero.
DxvkBufferCreateInfo bufferInfo;
bufferInfo.size = 0x10000; // Max constant buffer size
bufferInfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT
| VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
| VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
| VK_BUFFER_USAGE_INDEX_BUFFER_BIT
| VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
bufferInfo.stages = VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
| VK_PIPELINE_STAGE_TRANSFER_BIT
| enabledShaderStages;
bufferInfo.access = VK_ACCESS_TRANSFER_WRITE_BIT
| VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
| VK_ACCESS_UNIFORM_READ_BIT;
this->buffer = device->createBuffer(bufferInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
// Create buffer view to use for texel buffer bindings.
DxvkBufferViewCreateInfo bufferViewInfo;
bufferViewInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
bufferViewInfo.rangeOffset = 0;
bufferViewInfo.rangeLength = bufferInfo.size;
this->bufferView = device->createBufferView(this->buffer, bufferViewInfo);
// TODO images and image views
// TODO initialize resources
}
D3D11DummyResources::~D3D11DummyResources() {
}
}

View File

@ -1,37 +0,0 @@
#pragma once
#include "../dxvk/dxvk_device.h"
namespace dxvk {
/**
* \brief D3D11 dummy resources
*
* Binding dummy resources to resource slots is
* required in cases where the application binds
* \c nullptr in order to keep the backend alive.
*/
struct D3D11DummyResources : public RcObject {
D3D11DummyResources(
const Rc<DxvkDevice>& device,
VkPipelineStageFlags enabledShaderStages);
~D3D11DummyResources();
Rc<DxvkSampler> sampler; ///< Dummy texture sampler
Rc<DxvkBuffer> buffer; ///< Dummy constant/vertex buffer
Rc<DxvkBufferView> bufferView; ///< Dummy buffer SRV or UAV
Rc<DxvkImage> image1D; ///< Dummy 1D image, used to back 1D and 1D Array views
Rc<DxvkImage> image2D; ///< Dummy 2D image, used to back 2D, 2D Array and Cube views
Rc<DxvkImage> image3D; ///< Dummy 3D image, used to back the 3D view
Rc<DxvkImageView> imageView1D; ///< 1D view
Rc<DxvkImageView> imageView1DArray; ///< 1D array view
Rc<DxvkImageView> imageView2D; ///< 2D view
Rc<DxvkImageView> imageView2DArray; ///< 2D array view
Rc<DxvkImageView> imageViewCube; ///< 2D cube view
Rc<DxvkImageView> imageViewCubeArray; ///< 2D cube array view
Rc<DxvkImageView> imageView3D; ///< 3D view
};
}

View File

@ -5,7 +5,6 @@ d3d11_src = [
'd3d11_context.cpp', 'd3d11_context.cpp',
'd3d11_depth_stencil.cpp', 'd3d11_depth_stencil.cpp',
'd3d11_device.cpp', 'd3d11_device.cpp',
'd3d11_dummy_resource.cpp',
'd3d11_enums.cpp', 'd3d11_enums.cpp',
'd3d11_input_layout.cpp', 'd3d11_input_layout.cpp',
'd3d11_main.cpp', 'd3d11_main.cpp',