1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[d3d11] Implemented buffer creation

This commit is contained in:
Philip Rebohle 2017-12-07 13:31:32 +01:00
parent 5bf4ae7048
commit be7a70a307
4 changed files with 53 additions and 8 deletions

View File

@ -39,6 +39,18 @@ namespace dxvk {
}
UINT D3D11Buffer::GetEvictionPriority() {
UINT EvictionPriority = DXGI_RESOURCE_PRIORITY_NORMAL;
m_resource->GetEvictionPriority(&EvictionPriority);
return EvictionPriority;
}
void D3D11Buffer::SetEvictionPriority(UINT EvictionPriority) {
m_resource->SetEvictionPriority(EvictionPriority);
}
void D3D11Buffer::GetType(D3D11_RESOURCE_DIMENSION* pResourceDimension) {
*pResourceDimension = D3D11_RESOURCE_DIMENSION_BUFFER;
}

View File

@ -30,6 +30,10 @@ namespace dxvk {
void GetType(
D3D11_RESOURCE_DIMENSION *pResourceDimension) final;
UINT GetEvictionPriority() final;
void SetEvictionPriority(UINT EvictionPriority) final;
void GetDesc(
D3D11_BUFFER_DESC *pDesc) final;

View File

@ -62,6 +62,7 @@ namespace dxvk {
const D3D11_BUFFER_DESC* pDesc,
const D3D11_SUBRESOURCE_DATA* pInitialData,
ID3D11Buffer** ppBuffer) {
// Gather usage information
DxvkBufferCreateInfo info;
info.size = pDesc->ByteWidth;
@ -85,14 +86,14 @@ namespace dxvk {
if (pDesc->BindFlags & D3D11_BIND_CONSTANT_BUFFER) {
info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
info.stages |= enabledShaderPipelineStages;
info.stages |= GetEnabledShaderStages();
info.access |= VK_ACCESS_SHADER_READ_BIT;
}
if (pDesc->BindFlags & D3D11_BIND_SHADER_RESOURCE) {
info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
| VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
info.stages |= enabledShaderPipelineStages;
info.stages |= GetEnabledShaderStages();
info.access |= VK_ACCESS_SHADER_READ_BIT;
}
@ -110,18 +111,26 @@ namespace dxvk {
| VK_ACCESS_SHADER_WRITE_BIT;
}
if (info.MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) {
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) {
info.usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
info.stages |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
info.access |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
}
// Find the optimal memory type for the
// resource based on the usage pattern.
// Create the buffer if the application requests it
if (ppBuffer != nullptr) {
DXGICreateBufferResourcePrivate
Com<IDXGIBufferResourcePrivate> buffer;
HRESULT hr = DXGICreateBufferResourcePrivate(
m_dxgiDevice.ptr(), &info,
GetMemoryFlagsForUsage(pDesc->Usage), 0,
&buffer);
if (FAILED(hr))
return hr;
*ppBuffer = ref(new D3D11Buffer(
this, buffer.ptr(), *pDesc));
}
return S_OK;
@ -799,6 +808,24 @@ namespace dxvk {
}
VkPipelineStageFlags D3D11Device::GetEnabledShaderStages() const {
VkPipelineStageFlags enabledShaderPipelineStages
= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
| VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
| VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
if (m_dxvkDevice->features().geometryShader)
enabledShaderPipelineStages |= VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT;
if (m_dxvkDevice->features().tessellationShader) {
enabledShaderPipelineStages |= VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
| VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT;
}
return enabledShaderPipelineStages;
}
VkMemoryPropertyFlags D3D11Device::GetMemoryFlagsForUsage(D3D11_USAGE usage) const {
VkMemoryPropertyFlags memoryFlags = 0;

View File

@ -252,6 +252,8 @@ namespace dxvk {
size_t BytecodeLength,
ID3D11ClassLinkage* pClassLinkage);
VkPipelineStageFlags GetEnabledShaderStages() const;
VkMemoryPropertyFlags GetMemoryFlagsForUsage(
D3D11_USAGE usage) const;