mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-27 13:54:16 +01:00
[d3d11] Move immediate constant buffers to non-mapped VRAM
This has the advantage that icbs can be defragmented and don't take up space in HVV chunks that would potentially go unused.
This commit is contained in:
parent
6f59124e9a
commit
43f360d20c
@ -429,6 +429,13 @@ namespace dxvk {
|
|||||||
m_initializer->NotifyContextFlush();
|
m_initializer->NotifyContextFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitShaderIcb(
|
||||||
|
D3D11CommonShader* pShader,
|
||||||
|
size_t IcbSize,
|
||||||
|
const void* pIcbData) {
|
||||||
|
return m_initializer->InitShaderIcb(pShader, IcbSize, pIcbData);
|
||||||
|
}
|
||||||
|
|
||||||
VkPipelineStageFlags GetEnabledShaderStages() const {
|
VkPipelineStageFlags GetEnabledShaderStages() const {
|
||||||
return m_dxvkDevice->getShaderPipelineStages();
|
return m_dxvkDevice->getShaderPipelineStages();
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,33 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D11Initializer::InitShaderIcb(
|
||||||
|
D3D11CommonShader* pShader,
|
||||||
|
size_t IcbSize,
|
||||||
|
const void* pIcbData) {
|
||||||
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
|
m_transferCommands += 1;
|
||||||
|
|
||||||
|
auto icbSlice = pShader->GetIcb();
|
||||||
|
auto srcSlice = m_stagingBuffer.alloc(icbSlice.length());
|
||||||
|
|
||||||
|
std::memcpy(srcSlice.mapPtr(0), pIcbData, IcbSize);
|
||||||
|
|
||||||
|
if (IcbSize < icbSlice.length())
|
||||||
|
std::memset(srcSlice.mapPtr(IcbSize), 0, icbSlice.length() - IcbSize);
|
||||||
|
|
||||||
|
EmitCs([
|
||||||
|
cIcbSlice = std::move(icbSlice),
|
||||||
|
cSrcSlice = std::move(srcSlice)
|
||||||
|
] (DxvkContext* ctx) {
|
||||||
|
ctx->copyBuffer(cIcbSlice.buffer(), cIcbSlice.offset(),
|
||||||
|
cSrcSlice.buffer(), cSrcSlice.offset(), cIcbSlice.length());
|
||||||
|
});
|
||||||
|
|
||||||
|
ThrottleAllocationLocked();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11Initializer::InitDeviceLocalBuffer(
|
void D3D11Initializer::InitDeviceLocalBuffer(
|
||||||
D3D11Buffer* pBuffer,
|
D3D11Buffer* pBuffer,
|
||||||
const D3D11_SUBRESOURCE_DATA* pInitialData) {
|
const D3D11_SUBRESOURCE_DATA* pInitialData) {
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
#include "../dxvk/dxvk_staging.h"
|
#include "../dxvk/dxvk_staging.h"
|
||||||
|
|
||||||
#include "d3d11_buffer.h"
|
#include "d3d11_buffer.h"
|
||||||
|
#include "d3d11_shader.h"
|
||||||
#include "d3d11_texture.h"
|
#include "d3d11_texture.h"
|
||||||
|
#include "d3d11_view_uav.h"
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
@ -57,6 +59,11 @@ namespace dxvk {
|
|||||||
void InitUavCounter(
|
void InitUavCounter(
|
||||||
D3D11UnorderedAccessView* pUav);
|
D3D11UnorderedAccessView* pUav);
|
||||||
|
|
||||||
|
void InitShaderIcb(
|
||||||
|
D3D11CommonShader* pShader,
|
||||||
|
size_t IcbSize,
|
||||||
|
const void* pIcbData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
dxvk::mutex m_mutex;
|
dxvk::mutex m_mutex;
|
||||||
|
@ -64,19 +64,17 @@ namespace dxvk {
|
|||||||
if (icb.size) {
|
if (icb.size) {
|
||||||
DxvkBufferCreateInfo info = { };
|
DxvkBufferCreateInfo info = { };
|
||||||
info.size = align(icb.size, 256u);
|
info.size = align(icb.size, 256u);
|
||||||
info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
|
info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
|
||||||
|
| VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||||
info.stages = util::pipelineStages(m_shader->info().stage);
|
info.stages = util::pipelineStages(m_shader->info().stage);
|
||||||
info.access = VK_ACCESS_UNIFORM_READ_BIT;
|
info.access = VK_ACCESS_UNIFORM_READ_BIT
|
||||||
|
| VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
info.debugName = "Icb";
|
info.debugName = "Icb";
|
||||||
|
|
||||||
VkMemoryPropertyFlags memFlags
|
m_buffer = pDevice->GetDXVKDevice()->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
|
|
||||||
| VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
|
|
||||||
| VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
|
|
||||||
|
|
||||||
m_buffer = pDevice->GetDXVKDevice()->createBuffer(info, memFlags);
|
// Upload immediate constant buffer to VRAM
|
||||||
std::memcpy(m_buffer->mapPtr(0), icb.data, icb.size);
|
pDevice->InitShaderIcb(this, icb.size, icb.data);
|
||||||
std::memset(m_buffer->mapPtr(icb.size), 0, info.size - icb.size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pDevice->GetDXVKDevice()->registerShader(m_shader);
|
pDevice->GetDXVKDevice()->registerShader(m_shader);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user