mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 10:24:12 +01:00
[d3d11] Implemented buffer mapping
This commit is contained in:
parent
52f1c4fa00
commit
cd4f21a0c3
@ -143,15 +143,48 @@ namespace dxvk {
|
||||
D3D11_MAP MapType,
|
||||
UINT MapFlags,
|
||||
D3D11_MAPPED_SUBRESOURCE* pMappedResource) {
|
||||
Logger::err("D3D11DeviceContext::Map: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
D3D11_RESOURCE_DIMENSION resourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
||||
pResource->GetType(&resourceDim);
|
||||
|
||||
if (resourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
||||
D3D11Buffer* resource = static_cast<D3D11Buffer*>(pResource);
|
||||
|
||||
const Rc<DxvkBuffer> buffer = resource->GetDXVKBuffer();
|
||||
|
||||
if (buffer->mapPtr(0) == nullptr) {
|
||||
Logger::err("D3D11: Cannot map a device-local buffer");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (pMappedResource == nullptr)
|
||||
return S_OK;
|
||||
|
||||
if (buffer->isInUse()) {
|
||||
if (MapFlags & D3D11_MAP_FLAG_DO_NOT_WAIT)
|
||||
return DXGI_ERROR_WAS_STILL_DRAWING;
|
||||
|
||||
this->Flush();
|
||||
m_device->waitForIdle();
|
||||
// TODO properly synchronize
|
||||
}
|
||||
|
||||
pMappedResource->pData = buffer->mapPtr(0);
|
||||
pMappedResource->RowPitch = buffer->info().size;
|
||||
pMappedResource->DepthPitch = buffer->info().size;
|
||||
return E_FAIL;
|
||||
} else {
|
||||
Logger::err("D3D11: Mapping of image resources currently not supported");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void D3D11DeviceContext::Unmap(
|
||||
ID3D11Resource* pResource,
|
||||
UINT Subresource) {
|
||||
Logger::err("D3D11DeviceContext::Unmap: Not implemented");
|
||||
// There's literally nothing we have to do here at the moment
|
||||
this->Flush();
|
||||
m_device->waitForIdle();
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,6 +114,16 @@ namespace dxvk {
|
||||
| VK_ACCESS_SHADER_WRITE_BIT;
|
||||
}
|
||||
|
||||
if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_WRITE) {
|
||||
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
|
||||
info.access |= VK_ACCESS_HOST_WRITE_BIT;
|
||||
}
|
||||
|
||||
if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_READ) {
|
||||
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
|
||||
info.access |= VK_ACCESS_HOST_READ_BIT;
|
||||
}
|
||||
|
||||
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS) {
|
||||
info.usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
|
||||
info.stages |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
|
||||
@ -205,8 +215,16 @@ namespace dxvk {
|
||||
| VK_ACCESS_SHADER_WRITE_BIT;
|
||||
}
|
||||
|
||||
if (pDesc->CPUAccessFlags != 0)
|
||||
info.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
if (pDesc->CPUAccessFlags != 0) {
|
||||
info.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
|
||||
|
||||
if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_WRITE)
|
||||
info.access |= VK_ACCESS_HOST_WRITE_BIT;
|
||||
|
||||
if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_READ)
|
||||
info.access |= VK_ACCESS_HOST_READ_BIT;
|
||||
}
|
||||
|
||||
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE)
|
||||
info.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
|
||||
|
Loading…
Reference in New Issue
Block a user