2017-11-29 20:19:40 +01:00
|
|
|
#include <cstring>
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
#include "d3d11_context.h"
|
|
|
|
#include "d3d11_device.h"
|
2018-01-01 20:59:54 +01:00
|
|
|
#include "d3d11_query.h"
|
2017-12-25 20:40:48 +01:00
|
|
|
#include "d3d11_texture.h"
|
2017-10-11 09:51:48 +02:00
|
|
|
|
2017-12-08 22:30:41 +01:00
|
|
|
#include "../dxbc/dxbc_util.h"
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
namespace dxvk {
|
|
|
|
|
2017-10-11 15:32:24 +02:00
|
|
|
D3D11DeviceContext::D3D11DeviceContext(
|
2018-01-23 09:23:31 +01:00
|
|
|
D3D11Device* pParent,
|
|
|
|
Rc<DxvkDevice> Device)
|
|
|
|
: m_parent (pParent),
|
|
|
|
m_device (Device),
|
2018-01-20 22:52:18 +01:00
|
|
|
m_csChunk (new DxvkCsChunk()) {
|
2017-12-11 14:11:18 +01:00
|
|
|
// Create default state objects. We won't ever return them
|
|
|
|
// to the application, but we'll use them to apply state.
|
|
|
|
Com<ID3D11BlendState> defaultBlendState;
|
|
|
|
Com<ID3D11DepthStencilState> defaultDepthStencilState;
|
|
|
|
Com<ID3D11RasterizerState> defaultRasterizerState;
|
|
|
|
|
|
|
|
if (FAILED(m_parent->CreateBlendState (nullptr, &defaultBlendState))
|
|
|
|
|| FAILED(m_parent->CreateDepthStencilState(nullptr, &defaultDepthStencilState))
|
|
|
|
|| FAILED(m_parent->CreateRasterizerState (nullptr, &defaultRasterizerState)))
|
|
|
|
throw DxvkError("D3D11DeviceContext: Failed to create default state objects");
|
|
|
|
|
|
|
|
// Apply default state to the context. This is required
|
|
|
|
// in order to initialize the DXVK contex properly.
|
2018-01-20 18:01:43 +01:00
|
|
|
m_defaultBlendState = static_cast<D3D11BlendState*> (defaultBlendState.ptr());
|
2017-12-11 14:11:18 +01:00
|
|
|
m_defaultDepthStencilState = static_cast<D3D11DepthStencilState*>(defaultDepthStencilState.ptr());
|
2018-01-20 18:01:43 +01:00
|
|
|
m_defaultRasterizerState = static_cast<D3D11RasterizerState*> (defaultRasterizerState.ptr());
|
2018-01-10 19:07:55 +01:00
|
|
|
|
|
|
|
// Create a default sampler that we're going to bind
|
|
|
|
// when the application binds null to a sampler slot.
|
|
|
|
m_defaultSampler = CreateDefaultSampler();
|
2018-01-20 18:01:43 +01:00
|
|
|
|
|
|
|
EmitCs([
|
|
|
|
dev = m_device,
|
|
|
|
bsState = m_defaultBlendState,
|
|
|
|
dsState = m_defaultDepthStencilState,
|
|
|
|
rsState = m_defaultRasterizerState,
|
|
|
|
blendConst = DxvkBlendConstants {
|
|
|
|
m_state.om.blendFactor[0], m_state.om.blendFactor[1],
|
|
|
|
m_state.om.blendFactor[2], m_state.om.blendFactor[3] },
|
|
|
|
stencilRef = m_state.om.stencilRef
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->beginRecording(dev->createCommandList());
|
|
|
|
|
|
|
|
bsState->BindToContext(ctx, 0xFFFFFFFF);
|
|
|
|
dsState->BindToContext(ctx);
|
|
|
|
rsState->BindToContext(ctx);
|
|
|
|
|
|
|
|
ctx->setBlendConstants (blendConst);
|
|
|
|
ctx->setStencilReference(stencilRef);
|
|
|
|
});
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
D3D11DeviceContext::~D3D11DeviceContext() {
|
2017-11-26 14:01:41 +01:00
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE D3D11DeviceContext::QueryInterface(
|
2017-10-11 09:51:48 +02:00
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject) {
|
2017-10-15 21:50:34 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
|
|
|
|
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
|
2017-10-11 09:51:48 +02:00
|
|
|
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceContext);
|
|
|
|
|
|
|
|
Logger::warn("D3D11DeviceContext::QueryInterface: Unknown interface query");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GetDevice(ID3D11Device **ppDevice) {
|
2017-10-11 15:32:24 +02:00
|
|
|
*ppDevice = ref(m_parent);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ClearState() {
|
2017-12-07 12:45:02 +01:00
|
|
|
this->IASetInputLayout(nullptr);
|
2017-12-06 18:54:01 +01:00
|
|
|
this->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED);
|
2017-12-09 15:57:05 +01:00
|
|
|
this->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0);
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) {
|
|
|
|
ID3D11Buffer* buffer = nullptr;
|
|
|
|
const UINT offset = 0;
|
|
|
|
const UINT stride = 0;
|
|
|
|
|
|
|
|
this->IASetVertexBuffers(i, 1, &buffer, &offset, &stride);
|
|
|
|
}
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
this->VSSetShader(nullptr, nullptr, 0);
|
|
|
|
this->HSSetShader(nullptr, nullptr, 0);
|
|
|
|
this->DSSetShader(nullptr, nullptr, 0);
|
2017-12-18 12:53:53 +01:00
|
|
|
this->GSSetShader(nullptr, nullptr, 0);
|
2017-12-07 10:12:48 +01:00
|
|
|
this->PSSetShader(nullptr, nullptr, 0);
|
2017-12-20 17:37:46 +01:00
|
|
|
this->CSSetShader(nullptr, nullptr, 0);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++) {
|
|
|
|
ID3D11Buffer* buffer = nullptr;
|
|
|
|
|
|
|
|
this->VSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
this->HSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
this->DSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
this->GSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
this->PSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
this->CSSetConstantBuffers(i, 1, &buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; i++) {
|
|
|
|
ID3D11ShaderResourceView* view = nullptr;
|
|
|
|
|
|
|
|
this->VSSetShaderResources(i, 1, &view);
|
|
|
|
this->HSSetShaderResources(i, 1, &view);
|
|
|
|
this->DSSetShaderResources(i, 1, &view);
|
|
|
|
this->GSSetShaderResources(i, 1, &view);
|
|
|
|
this->PSSetShaderResources(i, 1, &view);
|
|
|
|
this->CSSetShaderResources(i, 1, &view);
|
|
|
|
}
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; i++) {
|
|
|
|
ID3D11SamplerState* sampler = nullptr;
|
|
|
|
|
|
|
|
this->VSSetSamplers(i, 1, &sampler);
|
|
|
|
this->HSSetSamplers(i, 1, &sampler);
|
|
|
|
this->DSSetSamplers(i, 1, &sampler);
|
|
|
|
this->GSSetSamplers(i, 1, &sampler);
|
|
|
|
this->PSSetSamplers(i, 1, &sampler);
|
|
|
|
this->CSSetSamplers(i, 1, &sampler);
|
|
|
|
}
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-28 19:05:53 +01:00
|
|
|
for (uint32_t i = 0; i < D3D11_1_UAV_SLOT_COUNT; i++) {
|
|
|
|
ID3D11UnorderedAccessView* uav = nullptr;
|
|
|
|
|
|
|
|
this->CSSetUnorderedAccessViews(i, 1, &uav, nullptr);
|
|
|
|
}
|
|
|
|
|
2017-12-06 12:11:59 +01:00
|
|
|
this->OMSetRenderTargets(0, nullptr, nullptr);
|
2017-12-10 01:56:07 +01:00
|
|
|
this->OMSetBlendState(nullptr, nullptr, D3D11_DEFAULT_SAMPLE_MASK);
|
|
|
|
this->OMSetDepthStencilState(nullptr, 0);
|
2017-12-06 12:11:59 +01:00
|
|
|
|
|
|
|
this->RSSetState(nullptr);
|
|
|
|
this->RSSetViewports(0, nullptr);
|
|
|
|
this->RSSetScissorRects(0, nullptr);
|
|
|
|
|
|
|
|
// this->SOSetTargets(0, nullptr, nullptr);
|
|
|
|
|
|
|
|
// this->SetPredication(nullptr, FALSE);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::Begin(ID3D11Asynchronous *pAsync) {
|
2018-01-02 12:07:30 +01:00
|
|
|
// Logger::err("D3D11DeviceContext::Begin: Not implemented");
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::End(ID3D11Asynchronous *pAsync) {
|
2018-01-02 12:07:30 +01:00
|
|
|
// Logger::err("D3D11DeviceContext::End: Not implemented");
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
HRESULT STDMETHODCALLTYPE D3D11DeviceContext::GetData(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Asynchronous* pAsync,
|
|
|
|
void* pData,
|
|
|
|
UINT DataSize,
|
|
|
|
UINT GetDataFlags) {
|
2018-01-01 20:59:54 +01:00
|
|
|
if (pAsync->GetDataSize() != DataSize) {
|
|
|
|
Logger::err("D3D11DeviceContext: GetData: Data size mismatch");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method handles various different but incompatible interfaces,
|
|
|
|
// so we have to find out what we are actually dealing with
|
|
|
|
Com<ID3D11Query> query;
|
|
|
|
|
|
|
|
if (SUCCEEDED(pAsync->QueryInterface(__uuidof(ID3D11Query), reinterpret_cast<void**>(&query))))
|
|
|
|
return static_cast<D3D11Query*>(query.ptr())->GetData(pData, GetDataFlags);
|
|
|
|
|
|
|
|
// The interface is not supported
|
|
|
|
Logger::err("D3D11DeviceContext: GetData: Unsupported Async type");
|
|
|
|
return E_INVALIDARG;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::SetPredication(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Predicate* pPredicate,
|
|
|
|
WINBOOL PredicateValue) {
|
|
|
|
Logger::err("D3D11DeviceContext::SetPredication: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GetPredication(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Predicate** ppPredicate,
|
|
|
|
WINBOOL* pPredicateValue) {
|
|
|
|
Logger::err("D3D11DeviceContext::GetPredication: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CopySubresourceRegion(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
UINT DstX,
|
|
|
|
UINT DstY,
|
|
|
|
UINT DstZ,
|
|
|
|
ID3D11Resource* pSrcResource,
|
|
|
|
UINT SrcSubresource,
|
|
|
|
const D3D11_BOX* pSrcBox) {
|
2017-12-30 19:10:45 +01:00
|
|
|
D3D11_RESOURCE_DIMENSION dstResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
|
|
|
D3D11_RESOURCE_DIMENSION srcResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
|
|
|
|
|
|
|
pDstResource->GetType(&dstResourceDim);
|
|
|
|
pSrcResource->GetType(&srcResourceDim);
|
|
|
|
|
|
|
|
if (dstResourceDim != srcResourceDim) {
|
|
|
|
Logger::err("D3D11DeviceContext: CopySubresourceRegion: Mismatched resource types");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dstResourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
|
|
|
Logger::err("D3D11DeviceContext::CopySubresourceRegion: Buffers not supported");
|
|
|
|
} else {
|
2018-01-05 01:15:56 +01:00
|
|
|
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
|
|
|
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
2017-12-30 19:10:45 +01:00
|
|
|
|
2018-01-06 02:09:07 +01:00
|
|
|
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
|
|
|
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
|
|
|
|
|
|
|
const VkImageSubresource dstSubresource =
|
|
|
|
GetSubresourceFromIndex(
|
|
|
|
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
|
|
|
|
dstTextureInfo->image->info().mipLevels, DstSubresource);
|
|
|
|
|
|
|
|
const VkImageSubresource srcSubresource =
|
|
|
|
GetSubresourceFromIndex(
|
|
|
|
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
|
|
|
|
srcTextureInfo->image->info().mipLevels, SrcSubresource);
|
|
|
|
|
2017-12-30 19:10:45 +01:00
|
|
|
VkOffset3D srcOffset = { 0, 0, 0 };
|
|
|
|
VkOffset3D dstOffset = {
|
|
|
|
static_cast<int32_t>(DstX),
|
|
|
|
static_cast<int32_t>(DstY),
|
|
|
|
static_cast<int32_t>(DstZ) };
|
|
|
|
|
2018-01-06 02:09:07 +01:00
|
|
|
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(srcSubresource.mipLevel);
|
2017-12-30 19:10:45 +01:00
|
|
|
|
|
|
|
if (pSrcBox != nullptr) {
|
|
|
|
if (pSrcBox->left >= pSrcBox->right
|
|
|
|
|| pSrcBox->top >= pSrcBox->bottom
|
|
|
|
|| pSrcBox->front >= pSrcBox->back)
|
|
|
|
return; // no-op, but legal
|
|
|
|
|
|
|
|
srcOffset.x = pSrcBox->left;
|
|
|
|
srcOffset.y = pSrcBox->top;
|
|
|
|
srcOffset.z = pSrcBox->front;
|
|
|
|
|
|
|
|
extent.width = pSrcBox->right - pSrcBox->left;
|
|
|
|
extent.height = pSrcBox->bottom - pSrcBox->top;
|
|
|
|
extent.depth = pSrcBox->back - pSrcBox->front;
|
|
|
|
}
|
|
|
|
|
2017-12-31 00:25:19 +01:00
|
|
|
const VkImageSubresourceLayers dstLayers = {
|
|
|
|
dstSubresource.aspectMask,
|
|
|
|
dstSubresource.mipLevel,
|
|
|
|
dstSubresource.arrayLayer, 1 };
|
|
|
|
|
|
|
|
const VkImageSubresourceLayers srcLayers = {
|
|
|
|
srcSubresource.aspectMask,
|
|
|
|
srcSubresource.mipLevel,
|
|
|
|
srcSubresource.arrayLayer, 1 };
|
2017-12-30 19:10:45 +01:00
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cDstImage = dstTextureInfo->image,
|
|
|
|
cSrcImage = srcTextureInfo->image,
|
|
|
|
cDstLayers = dstLayers,
|
|
|
|
cSrcLayers = srcLayers,
|
|
|
|
cDstOffset = dstOffset,
|
|
|
|
cSrcOffset = srcOffset,
|
|
|
|
cExtent = extent
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->copyImage(
|
|
|
|
cDstImage, cDstLayers, cDstOffset,
|
|
|
|
cSrcImage, cSrcLayers, cSrcOffset,
|
|
|
|
cExtent);
|
|
|
|
});
|
2017-12-30 19:10:45 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CopyResource(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
ID3D11Resource* pSrcResource) {
|
2017-12-28 19:05:53 +01:00
|
|
|
D3D11_RESOURCE_DIMENSION dstResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
|
|
|
D3D11_RESOURCE_DIMENSION srcResourceDim = D3D11_RESOURCE_DIMENSION_UNKNOWN;
|
|
|
|
|
|
|
|
pDstResource->GetType(&dstResourceDim);
|
|
|
|
pSrcResource->GetType(&srcResourceDim);
|
|
|
|
|
|
|
|
if (dstResourceDim != srcResourceDim) {
|
|
|
|
Logger::err("D3D11DeviceContext: CopyResource: Mismatched resource types");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dstResourceDim == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
|
|
|
auto dstBuffer = static_cast<D3D11Buffer*>(pDstResource)->GetBufferSlice();
|
|
|
|
auto srcBuffer = static_cast<D3D11Buffer*>(pSrcResource)->GetBufferSlice();
|
|
|
|
|
|
|
|
if (dstBuffer.length() != srcBuffer.length()) {
|
|
|
|
Logger::err("D3D11DeviceContext: CopyResource: Mismatched buffer size");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cDstBuffer = std::move(dstBuffer),
|
|
|
|
cSrcBuffer = std::move(srcBuffer)
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->copyBuffer(
|
|
|
|
cDstBuffer.buffer(),
|
|
|
|
cDstBuffer.offset(),
|
|
|
|
cSrcBuffer.buffer(),
|
|
|
|
cSrcBuffer.offset(),
|
|
|
|
cSrcBuffer.length());
|
|
|
|
});
|
2017-12-28 19:05:53 +01:00
|
|
|
} else {
|
2018-01-14 10:39:59 +01:00
|
|
|
const D3D11TextureInfo* dstTextureInfo = GetCommonTextureInfo(pDstResource);
|
|
|
|
const D3D11TextureInfo* srcTextureInfo = GetCommonTextureInfo(pSrcResource);
|
|
|
|
|
2018-01-14 21:17:51 +01:00
|
|
|
const DxvkFormatInfo* dstFormatInfo = imageFormatInfo(dstTextureInfo->image->info().format);
|
|
|
|
const DxvkFormatInfo* srcFormatInfo = imageFormatInfo(srcTextureInfo->image->info().format);
|
2018-01-14 10:39:59 +01:00
|
|
|
|
2018-01-14 21:17:51 +01:00
|
|
|
for (uint32_t i = 0; i < srcTextureInfo->image->info().mipLevels; i++) {
|
|
|
|
VkExtent3D extent = srcTextureInfo->image->mipLevelExtent(i);
|
2018-01-14 10:39:59 +01:00
|
|
|
|
2018-01-14 21:17:51 +01:00
|
|
|
const VkImageSubresourceLayers dstLayers = {
|
|
|
|
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
|
|
|
|
i, 0, dstTextureInfo->image->info().numLayers };
|
2018-01-14 10:39:59 +01:00
|
|
|
|
2018-01-14 21:17:51 +01:00
|
|
|
const VkImageSubresourceLayers srcLayers = {
|
|
|
|
dstFormatInfo->aspectMask & srcFormatInfo->aspectMask,
|
|
|
|
i, 0, srcTextureInfo->image->info().numLayers };
|
2018-01-20 19:30:31 +01:00
|
|
|
|
|
|
|
EmitCs([
|
|
|
|
cDstImage = dstTextureInfo->image,
|
|
|
|
cSrcImage = srcTextureInfo->image,
|
|
|
|
cDstLayers = dstLayers,
|
|
|
|
cSrcLayers = srcLayers,
|
|
|
|
cExtent = extent
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->copyImage(
|
|
|
|
cDstImage, cDstLayers, VkOffset3D { 0, 0, 0 },
|
2018-01-21 01:57:12 +01:00
|
|
|
cSrcImage, cSrcLayers, VkOffset3D { 0, 0, 0 },
|
2018-01-20 19:30:31 +01:00
|
|
|
cExtent);
|
|
|
|
});
|
2018-01-14 21:17:51 +01:00
|
|
|
}
|
2017-12-28 19:05:53 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
2018-01-14 21:17:51 +01:00
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CopyStructureCount(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer* pDstBuffer,
|
|
|
|
UINT DstAlignedByteOffset,
|
|
|
|
ID3D11UnorderedAccessView* pSrcView) {
|
2018-01-11 12:23:55 +01:00
|
|
|
auto buf = static_cast<D3D11Buffer*>(pDstBuffer);
|
|
|
|
auto uav = static_cast<D3D11UnorderedAccessView*>(pSrcView);
|
2018-01-14 21:17:51 +01:00
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cDstSlice = buf->GetBufferSlice(DstAlignedByteOffset),
|
|
|
|
cSrcSlice = uav->GetCounterSlice()
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->copyBuffer(
|
|
|
|
cDstSlice.buffer(),
|
|
|
|
cDstSlice.offset(),
|
|
|
|
cSrcSlice.buffer(),
|
|
|
|
cSrcSlice.offset(),
|
|
|
|
sizeof(uint32_t));
|
|
|
|
});
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ClearRenderTargetView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11RenderTargetView* pRenderTargetView,
|
|
|
|
const FLOAT ColorRGBA[4]) {
|
2017-12-04 13:39:37 +01:00
|
|
|
auto rtv = static_cast<D3D11RenderTargetView*>(pRenderTargetView);
|
2018-01-11 12:23:55 +01:00
|
|
|
const Rc<DxvkImageView> dxvkView = rtv->GetImageView();
|
2017-12-01 00:52:39 +01:00
|
|
|
|
2017-11-29 20:19:40 +01:00
|
|
|
// Find out whether the given attachment is currently bound
|
|
|
|
// or not, and if it is, which attachment index it has.
|
|
|
|
int32_t attachmentIndex = -1;
|
|
|
|
|
2017-12-09 03:53:42 +01:00
|
|
|
for (uint32_t i = 0; i < m_state.om.renderTargetViews.size(); i++) {
|
|
|
|
if (m_state.om.renderTargetViews.at(i) == rtv)
|
|
|
|
attachmentIndex = i;
|
2017-11-29 20:19:40 +01:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:52:39 +01:00
|
|
|
// Copy the clear color into a clear value structure.
|
|
|
|
// This should also work for images that don nott have
|
|
|
|
// a floating point format.
|
|
|
|
VkClearColorValue clearValue;
|
|
|
|
std::memcpy(clearValue.float32, ColorRGBA,
|
|
|
|
sizeof(clearValue.float32));
|
2017-11-29 20:19:40 +01:00
|
|
|
|
2017-12-01 00:52:39 +01:00
|
|
|
if (attachmentIndex >= 0) {
|
|
|
|
// Image is bound to the pipeline for rendering. We can
|
|
|
|
// use the clear function that operates on attachments.
|
|
|
|
VkClearAttachment clearInfo;
|
|
|
|
clearInfo.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
clearInfo.colorAttachment = static_cast<uint32_t>(attachmentIndex);
|
|
|
|
clearInfo.clearValue.color = clearValue;
|
|
|
|
|
|
|
|
// Clear the full area. On FL 9.x, only the first array
|
|
|
|
// layer will be cleared, rather than all array layers.
|
|
|
|
VkClearRect clearRect;
|
|
|
|
clearRect.rect.offset.x = 0;
|
|
|
|
clearRect.rect.offset.y = 0;
|
2018-01-06 02:09:07 +01:00
|
|
|
clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width;
|
|
|
|
clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height;
|
2017-12-01 00:52:39 +01:00
|
|
|
clearRect.baseArrayLayer = 0;
|
2017-12-09 03:53:42 +01:00
|
|
|
clearRect.layerCount = dxvkView->imageInfo().numLayers;
|
2017-12-01 00:52:39 +01:00
|
|
|
|
|
|
|
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
|
|
|
clearRect.layerCount = 1;
|
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cClearInfo = clearInfo,
|
|
|
|
cClearRect = clearRect
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->clearRenderTarget(cClearInfo, cClearRect);
|
|
|
|
});
|
2017-12-01 00:52:39 +01:00
|
|
|
} else {
|
|
|
|
// Image is not bound to the pipeline. We can still clear
|
|
|
|
// it, but we'll have to use a generic clear function.
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cClearValue = clearValue,
|
|
|
|
cDstView = dxvkView
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->clearColorImage(cDstView->image(),
|
|
|
|
cClearValue, cDstView->subresources());
|
|
|
|
});
|
2017-12-01 00:52:39 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ClearUnorderedAccessViewUint(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11UnorderedAccessView* pUnorderedAccessView,
|
|
|
|
const UINT Values[4]) {
|
|
|
|
Logger::err("D3D11DeviceContext::ClearUnorderedAccessViewUint: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ClearUnorderedAccessViewFloat(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11UnorderedAccessView* pUnorderedAccessView,
|
|
|
|
const FLOAT Values[4]) {
|
|
|
|
Logger::err("D3D11DeviceContext::ClearUnorderedAccessViewFloat: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ClearDepthStencilView(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DepthStencilView* pDepthStencilView,
|
|
|
|
UINT ClearFlags,
|
|
|
|
FLOAT Depth,
|
|
|
|
UINT8 Stencil) {
|
2017-12-09 03:53:42 +01:00
|
|
|
auto dsv = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
2018-01-11 12:23:55 +01:00
|
|
|
const Rc<DxvkImageView> dxvkView = dsv->GetImageView();
|
2017-12-09 03:53:42 +01:00
|
|
|
|
|
|
|
VkClearDepthStencilValue clearValue;
|
|
|
|
clearValue.depth = Depth;
|
|
|
|
clearValue.stencil = Stencil;
|
|
|
|
|
|
|
|
if (m_state.om.depthStencilView == dsv) {
|
|
|
|
// Image is bound to the pipeline for rendering. We can
|
|
|
|
// use the clear function that operates on attachments.
|
|
|
|
VkClearAttachment clearInfo;
|
|
|
|
clearInfo.aspectMask = 0;
|
|
|
|
clearInfo.colorAttachment = 0;
|
|
|
|
clearInfo.clearValue.depthStencil = clearValue;
|
|
|
|
|
|
|
|
if (ClearFlags & D3D11_CLEAR_DEPTH)
|
|
|
|
clearInfo.aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
|
|
|
|
|
|
if (ClearFlags & D3D11_CLEAR_STENCIL)
|
|
|
|
clearInfo.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
|
|
|
|
// Clear the full area
|
|
|
|
VkClearRect clearRect;
|
|
|
|
clearRect.rect.offset.x = 0;
|
|
|
|
clearRect.rect.offset.y = 0;
|
2018-01-06 02:09:07 +01:00
|
|
|
clearRect.rect.extent.width = dxvkView->mipLevelExtent(0).width;
|
|
|
|
clearRect.rect.extent.height = dxvkView->mipLevelExtent(0).height;
|
2017-12-09 03:53:42 +01:00
|
|
|
clearRect.baseArrayLayer = 0;
|
|
|
|
clearRect.layerCount = dxvkView->imageInfo().numLayers;
|
|
|
|
|
|
|
|
// FIXME Is this correct? Docs don't say anything
|
|
|
|
if (m_parent->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0)
|
|
|
|
clearRect.layerCount = 1;
|
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cClearInfo = clearInfo,
|
|
|
|
cClearRect = clearRect
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->clearRenderTarget(cClearInfo, cClearRect);
|
|
|
|
});
|
2017-12-09 03:53:42 +01:00
|
|
|
} else {
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cClearValue = clearValue,
|
|
|
|
cDstView = dxvkView
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->clearDepthStencilImage(cDstView->image(),
|
|
|
|
cClearValue, cDstView->subresources());
|
|
|
|
});
|
2017-12-09 03:53:42 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GenerateMips(ID3D11ShaderResourceView* pShaderResourceView) {
|
2018-01-20 09:46:54 +01:00
|
|
|
auto view = static_cast<D3D11ShaderResourceView*>(pShaderResourceView);
|
|
|
|
|
|
|
|
if (view->GetResourceType() != D3D11_RESOURCE_DIMENSION_BUFFER) {
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([cDstImageView = view->GetImageView()]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->generateMipmaps(
|
|
|
|
cDstImageView->image(),
|
|
|
|
cDstImageView->subresources());
|
|
|
|
});
|
2018-01-20 09:46:54 +01:00
|
|
|
} else {
|
|
|
|
Logger::err("D3D11DeviceContext: GenerateMips called on a buffer");
|
|
|
|
}
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::UpdateSubresource(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
const D3D11_BOX* pDstBox,
|
|
|
|
const void* pSrcData,
|
|
|
|
UINT SrcRowPitch,
|
|
|
|
UINT SrcDepthPitch) {
|
2017-12-08 19:39:33 +01:00
|
|
|
// We need a different code path for buffers
|
|
|
|
D3D11_RESOURCE_DIMENSION resourceType;
|
|
|
|
pDstResource->GetType(&resourceType);
|
|
|
|
|
|
|
|
if (resourceType == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
2017-12-14 19:07:08 +01:00
|
|
|
const auto bufferResource = static_cast<D3D11Buffer*>(pDstResource);
|
2017-12-15 19:11:10 +01:00
|
|
|
const auto bufferSlice = bufferResource->GetBufferSlice();
|
2017-12-08 19:39:33 +01:00
|
|
|
|
2018-01-20 21:42:11 +01:00
|
|
|
VkDeviceSize offset = bufferSlice.offset();
|
|
|
|
VkDeviceSize size = bufferSlice.length();
|
2017-12-08 19:39:33 +01:00
|
|
|
|
|
|
|
if (pDstBox != nullptr) {
|
|
|
|
offset = pDstBox->left;
|
|
|
|
size = pDstBox->right - pDstBox->left;
|
|
|
|
}
|
|
|
|
|
2017-12-14 19:11:13 +01:00
|
|
|
if (offset + size > bufferSlice.length()) {
|
2017-12-25 20:40:48 +01:00
|
|
|
Logger::err("D3D11DeviceContext: Buffer update range out of bounds");
|
2017-12-14 19:07:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-18 11:55:27 +01:00
|
|
|
if (size == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (((size == bufferSlice.length())
|
2018-01-18 18:50:44 +01:00
|
|
|
&& (bufferSlice.buffer()->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))) {
|
2018-01-23 12:16:28 +01:00
|
|
|
D3D11_MAPPED_SUBRESOURCE mappedSr;
|
|
|
|
Map(pDstResource, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedSr);
|
|
|
|
std::memcpy(mappedSr.pData, pSrcData, size);
|
|
|
|
Unmap(pDstResource, 0);
|
2018-01-18 11:55:27 +01:00
|
|
|
} else {
|
2018-01-23 16:43:55 +01:00
|
|
|
DxvkDataSlice dataSlice = AllocUpdateBufferSlice(size);
|
|
|
|
std::memcpy(dataSlice.ptr(), pSrcData, size);
|
|
|
|
|
2018-01-20 21:42:11 +01:00
|
|
|
EmitCs([
|
2018-01-23 16:43:55 +01:00
|
|
|
cDataBuffer = std::move(dataSlice),
|
2018-01-20 21:42:11 +01:00
|
|
|
cBufferSlice = bufferSlice.subSlice(offset, size)
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->updateBuffer(
|
|
|
|
cBufferSlice.buffer(),
|
|
|
|
cBufferSlice.offset(),
|
|
|
|
cBufferSlice.length(),
|
2018-01-23 16:43:55 +01:00
|
|
|
cDataBuffer.ptr());
|
2018-01-20 21:42:11 +01:00
|
|
|
});
|
2017-12-14 19:07:08 +01:00
|
|
|
}
|
2017-12-08 19:39:33 +01:00
|
|
|
} else {
|
2018-01-05 01:15:56 +01:00
|
|
|
const D3D11TextureInfo* textureInfo
|
|
|
|
= GetCommonTextureInfo(pDstResource);
|
2017-12-25 20:40:48 +01:00
|
|
|
|
2018-01-06 02:09:07 +01:00
|
|
|
const VkImageSubresource subresource =
|
|
|
|
GetSubresourceFromIndex(VK_IMAGE_ASPECT_COLOR_BIT,
|
|
|
|
textureInfo->image->info().mipLevels, DstSubresource);
|
|
|
|
|
2017-12-25 20:40:48 +01:00
|
|
|
VkOffset3D offset = { 0, 0, 0 };
|
2018-01-06 02:09:07 +01:00
|
|
|
VkExtent3D extent = textureInfo->image->mipLevelExtent(subresource.mipLevel);
|
2017-12-25 20:40:48 +01:00
|
|
|
|
|
|
|
if (pDstBox != nullptr) {
|
|
|
|
if (pDstBox->left >= pDstBox->right
|
|
|
|
|| pDstBox->top >= pDstBox->bottom
|
|
|
|
|| pDstBox->front >= pDstBox->back)
|
|
|
|
return; // no-op, but legal
|
|
|
|
|
|
|
|
offset.x = pDstBox->left;
|
|
|
|
offset.y = pDstBox->top;
|
|
|
|
offset.z = pDstBox->front;
|
|
|
|
|
|
|
|
extent.width = pDstBox->right - pDstBox->left;
|
|
|
|
extent.height = pDstBox->bottom - pDstBox->top;
|
|
|
|
extent.depth = pDstBox->back - pDstBox->front;
|
|
|
|
}
|
|
|
|
|
2018-01-06 02:09:07 +01:00
|
|
|
const VkImageSubresourceLayers layers = {
|
|
|
|
subresource.aspectMask,
|
|
|
|
subresource.mipLevel,
|
|
|
|
subresource.arrayLayer, 1 };
|
2017-12-25 20:40:48 +01:00
|
|
|
|
2018-01-20 21:42:11 +01:00
|
|
|
auto formatInfo = imageFormatInfo(
|
|
|
|
textureInfo->image->info().format);
|
|
|
|
|
|
|
|
const VkExtent3D regionExtent = util::computeBlockCount(extent, formatInfo->blockSize);
|
|
|
|
|
|
|
|
const VkDeviceSize bytesPerRow = regionExtent.width * formatInfo->elementSize;
|
|
|
|
const VkDeviceSize bytesPerLayer = regionExtent.height * bytesPerRow;
|
|
|
|
const VkDeviceSize bytesTotal = regionExtent.depth * bytesPerLayer;
|
|
|
|
|
2018-01-23 16:43:55 +01:00
|
|
|
DxvkDataSlice imageDataBuffer = AllocUpdateBufferSlice(bytesTotal);
|
2018-01-20 21:42:11 +01:00
|
|
|
|
|
|
|
util::packImageData(
|
2018-01-23 16:43:55 +01:00
|
|
|
reinterpret_cast<char*>(imageDataBuffer.ptr()),
|
2018-01-20 21:42:11 +01:00
|
|
|
reinterpret_cast<const char*>(pSrcData),
|
|
|
|
regionExtent, formatInfo->elementSize,
|
2017-12-25 20:40:48 +01:00
|
|
|
SrcRowPitch, SrcDepthPitch);
|
2018-01-20 21:42:11 +01:00
|
|
|
|
|
|
|
EmitCs([
|
|
|
|
cDstImage = textureInfo->image,
|
|
|
|
cDstLayers = layers,
|
|
|
|
cDstOffset = offset,
|
|
|
|
cDstExtent = extent,
|
|
|
|
cSrcData = std::move(imageDataBuffer),
|
|
|
|
cSrcBytesPerRow = bytesPerRow,
|
|
|
|
cSrcBytesPerLayer = bytesPerLayer
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->updateImage(cDstImage, cDstLayers,
|
2018-01-23 16:43:55 +01:00
|
|
|
cDstOffset, cDstExtent, cSrcData.ptr(),
|
2018-01-20 21:42:11 +01:00
|
|
|
cSrcBytesPerRow, cSrcBytesPerLayer);
|
|
|
|
});
|
2017-12-08 19:39:33 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::SetResourceMinLOD(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pResource,
|
|
|
|
FLOAT MinLOD) {
|
|
|
|
Logger::err("D3D11DeviceContext::SetResourceMinLOD: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
FLOAT STDMETHODCALLTYPE D3D11DeviceContext::GetResourceMinLOD(ID3D11Resource* pResource) {
|
2017-10-11 09:51:48 +02:00
|
|
|
Logger::err("D3D11DeviceContext::GetResourceMinLOD: Not implemented");
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::ResolveSubresource(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Resource* pDstResource,
|
|
|
|
UINT DstSubresource,
|
|
|
|
ID3D11Resource* pSrcResource,
|
|
|
|
UINT SrcSubresource,
|
|
|
|
DXGI_FORMAT Format) {
|
|
|
|
Logger::err("D3D11DeviceContext::ResolveSubresource: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawAuto() {
|
2017-10-11 09:51:48 +02:00
|
|
|
Logger::err("D3D11DeviceContext::DrawAuto: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::Draw(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT VertexCount,
|
|
|
|
UINT StartVertexLocation) {
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([=] (DxvkContext* ctx) {
|
|
|
|
ctx->draw(
|
|
|
|
VertexCount, 1,
|
|
|
|
StartVertexLocation, 0);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawIndexed(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT IndexCount,
|
|
|
|
UINT StartIndexLocation,
|
|
|
|
INT BaseVertexLocation) {
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([=] (DxvkContext* ctx) {
|
|
|
|
ctx->drawIndexed(
|
|
|
|
IndexCount, 1,
|
|
|
|
StartIndexLocation,
|
|
|
|
BaseVertexLocation, 0);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawInstanced(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT VertexCountPerInstance,
|
|
|
|
UINT InstanceCount,
|
|
|
|
UINT StartVertexLocation,
|
|
|
|
UINT StartInstanceLocation) {
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([=] (DxvkContext* ctx) {
|
|
|
|
ctx->draw(
|
|
|
|
VertexCountPerInstance,
|
|
|
|
InstanceCount,
|
|
|
|
StartVertexLocation,
|
|
|
|
StartInstanceLocation);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawIndexedInstanced(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT IndexCountPerInstance,
|
|
|
|
UINT InstanceCount,
|
|
|
|
UINT StartIndexLocation,
|
|
|
|
INT BaseVertexLocation,
|
|
|
|
UINT StartInstanceLocation) {
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([=] (DxvkContext* ctx) {
|
|
|
|
ctx->drawIndexed(
|
|
|
|
IndexCountPerInstance,
|
|
|
|
InstanceCount,
|
|
|
|
StartIndexLocation,
|
|
|
|
BaseVertexLocation,
|
|
|
|
StartInstanceLocation);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawIndexedInstancedIndirect(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer* pBufferForArgs,
|
|
|
|
UINT AlignedByteOffsetForArgs) {
|
2017-12-31 01:31:08 +01:00
|
|
|
D3D11Buffer* buffer = static_cast<D3D11Buffer*>(pBufferForArgs);
|
2017-12-31 00:25:19 +01:00
|
|
|
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([bufferSlice = buffer->GetBufferSlice(AlignedByteOffsetForArgs)]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->drawIndexedIndirect(
|
|
|
|
bufferSlice, 1, 0);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DrawInstancedIndirect(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer* pBufferForArgs,
|
|
|
|
UINT AlignedByteOffsetForArgs) {
|
2017-12-31 01:31:08 +01:00
|
|
|
D3D11Buffer* buffer = static_cast<D3D11Buffer*>(pBufferForArgs);
|
2017-12-31 00:25:19 +01:00
|
|
|
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([bufferSlice = buffer->GetBufferSlice(AlignedByteOffsetForArgs)]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->drawIndirect(bufferSlice, 1, 0);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::Dispatch(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT ThreadGroupCountX,
|
|
|
|
UINT ThreadGroupCountY,
|
|
|
|
UINT ThreadGroupCountZ) {
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([=] (DxvkContext* ctx) {
|
|
|
|
ctx->dispatch(
|
|
|
|
ThreadGroupCountX,
|
|
|
|
ThreadGroupCountY,
|
|
|
|
ThreadGroupCountZ);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DispatchIndirect(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer* pBufferForArgs,
|
|
|
|
UINT AlignedByteOffsetForArgs) {
|
2017-12-31 01:31:08 +01:00
|
|
|
D3D11Buffer* buffer = static_cast<D3D11Buffer*>(pBufferForArgs);
|
2017-12-31 00:25:19 +01:00
|
|
|
|
2018-01-20 18:26:17 +01:00
|
|
|
EmitCs([bufferSlice = buffer->GetBufferSlice(AlignedByteOffsetForArgs)]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->dispatchIndirect(bufferSlice);
|
|
|
|
});
|
|
|
|
|
2018-01-13 23:09:03 +01:00
|
|
|
m_drawCount += 1;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IASetInputLayout(ID3D11InputLayout* pInputLayout) {
|
2018-01-20 19:11:42 +01:00
|
|
|
Com<D3D11InputLayout> inputLayout =
|
|
|
|
static_cast<D3D11InputLayout*>(pInputLayout);
|
2017-12-07 12:45:02 +01:00
|
|
|
|
|
|
|
if (m_state.ia.inputLayout != inputLayout) {
|
|
|
|
m_state.ia.inputLayout = inputLayout;
|
|
|
|
|
2018-01-20 18:34:25 +01:00
|
|
|
if (inputLayout != nullptr) {
|
|
|
|
EmitCs([inputLayout] (DxvkContext* ctx) {
|
|
|
|
inputLayout->BindToContext(ctx);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
EmitCs([inputLayout] (DxvkContext* ctx) {
|
|
|
|
ctx->setInputLayout(0, nullptr, 0, nullptr);
|
|
|
|
});
|
|
|
|
}
|
2017-12-07 12:45:02 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY Topology) {
|
2017-12-06 18:54:01 +01:00
|
|
|
if (m_state.ia.primitiveTopology != Topology) {
|
|
|
|
m_state.ia.primitiveTopology = Topology;
|
|
|
|
|
2017-12-26 16:25:51 +01:00
|
|
|
if (Topology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
|
|
|
|
return;
|
2017-12-06 18:54:01 +01:00
|
|
|
|
2017-12-26 16:25:51 +01:00
|
|
|
const DxvkInputAssemblyState iaState = [&] () -> DxvkInputAssemblyState {
|
|
|
|
switch (Topology) {
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_FALSE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_FALSE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, VK_TRUE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, VK_TRUE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, VK_FALSE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, VK_TRUE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, VK_FALSE };
|
|
|
|
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ:
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, VK_TRUE };
|
|
|
|
|
|
|
|
default:
|
|
|
|
Logger::err(str::format("D3D11DeviceContext::IASetPrimitiveTopology: Unknown primitive topology: ", Topology));
|
|
|
|
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE };
|
|
|
|
}
|
2017-12-06 18:54:01 +01:00
|
|
|
|
2017-12-26 16:25:51 +01:00
|
|
|
}();
|
2017-12-06 18:54:01 +01:00
|
|
|
|
2018-01-20 18:34:25 +01:00
|
|
|
EmitCs([iaState] (DxvkContext* ctx) {
|
|
|
|
ctx->setInputAssemblyState(iaState);
|
|
|
|
});
|
2017-12-06 18:54:01 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IASetVertexBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppVertexBuffers,
|
|
|
|
const UINT* pStrides,
|
|
|
|
const UINT* pOffsets) {
|
2017-12-07 14:03:15 +01:00
|
|
|
// TODO check if any of these buffers
|
|
|
|
// are bound as UAVs or stream outputs
|
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++) {
|
2017-12-20 17:37:46 +01:00
|
|
|
auto newBuffer = static_cast<D3D11Buffer*>(ppVertexBuffers[i]);
|
2017-12-15 19:11:10 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.ia.vertexBuffers[i].buffer = newBuffer;
|
|
|
|
m_state.ia.vertexBuffers[i].offset = pOffsets[i];
|
|
|
|
m_state.ia.vertexBuffers[i].stride = pStrides[i];
|
2017-12-09 15:57:05 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
if (newBuffer != nullptr) {
|
2018-01-20 18:34:25 +01:00
|
|
|
EmitCs([
|
|
|
|
slotId = StartSlot + i,
|
|
|
|
offset = pOffsets[i],
|
|
|
|
stride = pStrides[i],
|
|
|
|
slice = newBuffer->GetBufferSlice(pOffsets[i])
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->bindVertexBuffer(
|
|
|
|
slotId, slice, stride);
|
|
|
|
});
|
2017-12-20 17:37:46 +01:00
|
|
|
} else {
|
2018-01-20 18:34:25 +01:00
|
|
|
EmitCs([cSlotId = StartSlot + i] (DxvkContext* ctx) {
|
|
|
|
ctx->bindVertexBuffer(cSlotId, DxvkBufferSlice(), 0);
|
|
|
|
});
|
2017-12-07 14:03:15 +01:00
|
|
|
}
|
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IASetIndexBuffer(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer* pIndexBuffer,
|
|
|
|
DXGI_FORMAT Format,
|
|
|
|
UINT Offset) {
|
2017-12-20 17:37:46 +01:00
|
|
|
auto newBuffer = static_cast<D3D11Buffer*>(pIndexBuffer);
|
2017-12-08 01:51:49 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.ia.indexBuffer.buffer = newBuffer;
|
|
|
|
m_state.ia.indexBuffer.offset = Offset;
|
|
|
|
m_state.ia.indexBuffer.format = Format;
|
2017-12-08 01:51:49 +01:00
|
|
|
|
|
|
|
// As in Vulkan, the index format can be either a 32-bit
|
|
|
|
// unsigned integer or a 16-bit unsigned integer, no other
|
|
|
|
// formats are allowed.
|
2017-12-20 17:37:46 +01:00
|
|
|
if (newBuffer != nullptr) {
|
|
|
|
VkIndexType indexType = VK_INDEX_TYPE_UINT32;
|
|
|
|
|
|
|
|
switch (Format) {
|
2017-12-09 15:57:05 +01:00
|
|
|
case DXGI_FORMAT_R16_UINT: indexType = VK_INDEX_TYPE_UINT16; break;
|
|
|
|
case DXGI_FORMAT_R32_UINT: indexType = VK_INDEX_TYPE_UINT32; break;
|
2017-12-20 17:37:46 +01:00
|
|
|
default: Logger::err(str::format("D3D11: Invalid index format: ", Format));
|
2017-12-09 15:57:05 +01:00
|
|
|
}
|
2017-12-20 17:37:46 +01:00
|
|
|
|
2018-01-20 18:34:25 +01:00
|
|
|
EmitCs([indexType,
|
|
|
|
slice = newBuffer->GetBufferSlice(Offset)
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->bindIndexBuffer(slice, indexType);
|
|
|
|
});
|
2017-12-08 01:51:49 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IAGetInputLayout(ID3D11InputLayout** ppInputLayout) {
|
2017-12-07 12:45:02 +01:00
|
|
|
*ppInputLayout = m_state.ia.inputLayout.ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IAGetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY* pTopology) {
|
2017-12-06 18:54:01 +01:00
|
|
|
*pTopology = m_state.ia.primitiveTopology;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IAGetVertexBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppVertexBuffers,
|
|
|
|
UINT* pStrides,
|
|
|
|
UINT* pOffsets) {
|
|
|
|
Logger::err("D3D11DeviceContext::IAGetVertexBuffers: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::IAGetIndexBuffer(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11Buffer** pIndexBuffer,
|
|
|
|
DXGI_FORMAT* Format,
|
|
|
|
UINT* Offset) {
|
|
|
|
Logger::err("D3D11DeviceContext::IAGetIndexBuffer: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11VertexShader* pVertexShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-07 10:12:48 +01:00
|
|
|
auto shader = static_cast<D3D11VertexShader*>(pVertexShader);
|
|
|
|
|
|
|
|
if (NumClassInstances != 0)
|
|
|
|
Logger::err("D3D11DeviceContext::VSSetShader: Class instances not supported");
|
|
|
|
|
|
|
|
if (m_state.vs.shader != shader) {
|
|
|
|
m_state.vs.shader = shader;
|
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindShader(VK_SHADER_STAGE_VERTEX_BIT, cShader);
|
|
|
|
});
|
2017-12-07 10:12:48 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-08 19:39:33 +01:00
|
|
|
this->BindConstantBuffers(
|
2017-12-08 22:30:41 +01:00
|
|
|
DxbcProgramType::VertexShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.vs.constantBuffers,
|
2017-12-08 19:39:33 +01:00
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-10 01:56:07 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::VertexShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.vs.shaderResources,
|
2017-12-10 01:56:07 +01:00
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-09 21:17:26 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::VertexShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.vs.samplers,
|
2017-12-09 21:17:26 +01:00
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11VertexShader** ppVertexShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-11 14:21:24 +01:00
|
|
|
if (ppVertexShader != nullptr)
|
|
|
|
*ppVertexShader = m_state.vs.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-11 14:21:24 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.vs.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.vs.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::VSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.vs.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11HullShader* pHullShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-11 17:01:38 +01:00
|
|
|
if (m_state.hs.shader.ptr() != pHullShader)
|
|
|
|
Logger::err("D3D11DeviceContext::HSSetShader: Not implemented");
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::HullShader,
|
|
|
|
m_state.hs.shaderResources,
|
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindConstantBuffers(
|
|
|
|
DxbcProgramType::HullShader,
|
|
|
|
m_state.hs.constantBuffers,
|
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::HullShader,
|
|
|
|
m_state.hs.samplers,
|
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11HullShader** ppHullShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-20 17:37:46 +01:00
|
|
|
if (ppHullShader != nullptr)
|
|
|
|
*ppHullShader = m_state.hs.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-20 17:37:46 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.hs.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.hs.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::HSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.hs.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DomainShader* pDomainShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-11 17:01:38 +01:00
|
|
|
if (m_state.ds.shader.ptr() != pDomainShader)
|
|
|
|
Logger::err("D3D11DeviceContext::DSSetShader: Not implemented");
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::DomainShader,
|
|
|
|
m_state.ds.shaderResources,
|
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindConstantBuffers(
|
|
|
|
DxbcProgramType::DomainShader,
|
|
|
|
m_state.ds.constantBuffers,
|
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::DomainShader,
|
|
|
|
m_state.ds.samplers,
|
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DomainShader** ppDomainShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-20 17:37:46 +01:00
|
|
|
if (ppDomainShader != nullptr)
|
|
|
|
*ppDomainShader = m_state.ds.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-20 17:37:46 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.ds.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.ds.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::DSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.ds.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11GeometryShader* pShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-18 12:53:53 +01:00
|
|
|
auto shader = static_cast<D3D11GeometryShader*>(pShader);
|
|
|
|
|
|
|
|
if (NumClassInstances != 0)
|
|
|
|
Logger::err("D3D11DeviceContext::GSSetShader: Class instances not supported");
|
|
|
|
|
|
|
|
if (m_state.gs.shader != shader) {
|
|
|
|
m_state.gs.shader = shader;
|
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindShader(VK_SHADER_STAGE_GEOMETRY_BIT, cShader);
|
|
|
|
});
|
2017-12-18 12:53:53 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-18 12:53:53 +01:00
|
|
|
this->BindConstantBuffers(
|
|
|
|
DxbcProgramType::GeometryShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.gs.constantBuffers,
|
2017-12-18 12:53:53 +01:00
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-18 12:53:53 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::GeometryShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.gs.shaderResources,
|
2017-12-18 12:53:53 +01:00
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-18 12:53:53 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::GeometryShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.gs.samplers,
|
2017-12-18 12:53:53 +01:00
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11GeometryShader** ppGeometryShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-18 12:53:53 +01:00
|
|
|
if (ppGeometryShader != nullptr)
|
|
|
|
*ppGeometryShader = m_state.gs.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-18 12:53:53 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-18 12:53:53 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.gs.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-18 12:53:53 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.gs.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::GSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-18 12:53:53 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.gs.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11PixelShader* pPixelShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-07 10:12:48 +01:00
|
|
|
auto shader = static_cast<D3D11PixelShader*>(pPixelShader);
|
|
|
|
|
|
|
|
if (NumClassInstances != 0)
|
2017-12-07 12:45:02 +01:00
|
|
|
Logger::err("D3D11DeviceContext::PSSetShader: Class instances not supported");
|
2017-12-07 10:12:48 +01:00
|
|
|
|
|
|
|
if (m_state.ps.shader != shader) {
|
|
|
|
m_state.ps.shader = shader;
|
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, cShader);
|
|
|
|
});
|
2017-12-07 10:12:48 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-08 19:39:33 +01:00
|
|
|
this->BindConstantBuffers(
|
2017-12-08 22:30:41 +01:00
|
|
|
DxbcProgramType::PixelShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.ps.constantBuffers,
|
2017-12-08 19:39:33 +01:00
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-10 01:56:07 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::PixelShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.ps.shaderResources,
|
2017-12-10 01:56:07 +01:00
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-09 21:17:26 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::PixelShader,
|
2017-12-20 17:37:46 +01:00
|
|
|
m_state.ps.samplers,
|
2017-12-09 21:17:26 +01:00
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11PixelShader** ppPixelShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-11 14:21:24 +01:00
|
|
|
if (ppPixelShader != nullptr)
|
|
|
|
*ppPixelShader = m_state.ps.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-11 14:21:24 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-11 14:21:24 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.ps.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-11 14:21:24 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.ps.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::PSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-11 14:21:24 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.ps.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSSetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11ComputeShader* pComputeShader,
|
|
|
|
ID3D11ClassInstance* const* ppClassInstances,
|
|
|
|
UINT NumClassInstances) {
|
2017-12-21 17:27:40 +01:00
|
|
|
auto shader = static_cast<D3D11ComputeShader*>(pComputeShader);
|
|
|
|
|
|
|
|
if (NumClassInstances != 0)
|
|
|
|
Logger::err("D3D11DeviceContext::CSSetShader: Class instances not supported");
|
|
|
|
|
|
|
|
if (m_state.cs.shader != shader) {
|
|
|
|
m_state.cs.shader = shader;
|
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cShader = shader != nullptr ? shader->GetShader() : nullptr]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindShader(VK_SHADER_STAGE_COMPUTE_BIT, cShader);
|
|
|
|
});
|
2017-12-21 17:27:40 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSSetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindConstantBuffers(
|
|
|
|
DxbcProgramType::ComputeShader,
|
|
|
|
m_state.cs.constantBuffers,
|
|
|
|
StartSlot, NumBuffers,
|
|
|
|
ppConstantBuffers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSSetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView* const* ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindShaderResources(
|
|
|
|
DxbcProgramType::ComputeShader,
|
|
|
|
m_state.cs.shaderResources,
|
|
|
|
StartSlot, NumViews,
|
|
|
|
ppShaderResourceViews);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSSetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
this->BindSamplers(
|
|
|
|
DxbcProgramType::ComputeShader,
|
|
|
|
m_state.cs.samplers,
|
|
|
|
StartSlot, NumSamplers,
|
|
|
|
ppSamplers);
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSSetUnorderedAccessViews(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
|
|
|
|
const UINT* pUAVInitialCounts) {
|
2017-12-28 19:05:53 +01:00
|
|
|
this->BindUnorderedAccessViews(
|
|
|
|
DxbcProgramType::ComputeShader,
|
|
|
|
m_state.cs.unorderedAccessViews,
|
|
|
|
StartSlot, NumUAVs,
|
|
|
|
ppUnorderedAccessViews);
|
2018-01-11 12:23:55 +01:00
|
|
|
|
|
|
|
if (pUAVInitialCounts != nullptr) {
|
|
|
|
this->InitUnorderedAccessViewCounters(
|
|
|
|
NumUAVs, ppUnorderedAccessViews,
|
|
|
|
pUAVInitialCounts);
|
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSGetShader(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11ComputeShader** ppComputeShader,
|
|
|
|
ID3D11ClassInstance** ppClassInstances,
|
|
|
|
UINT* pNumClassInstances) {
|
2017-12-20 17:37:46 +01:00
|
|
|
if (ppComputeShader != nullptr)
|
|
|
|
*ppComputeShader = m_state.cs.shader.ref();
|
|
|
|
|
2018-01-17 23:49:26 +01:00
|
|
|
if (pNumClassInstances != nullptr)
|
2017-12-20 17:37:46 +01:00
|
|
|
*pNumClassInstances = 0;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSGetConstantBuffers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++)
|
|
|
|
ppConstantBuffers[i] = m_state.cs.constantBuffers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSGetShaderResources(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumViews,
|
|
|
|
ID3D11ShaderResourceView** ppShaderResourceViews) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumViews; i++)
|
|
|
|
ppShaderResourceViews[i] = m_state.cs.shaderResources.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSGetSamplers(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState** ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++)
|
|
|
|
ppSamplers[i] = m_state.cs.samplers.at(StartSlot + i).ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::CSGetUnorderedAccessViews(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView** ppUnorderedAccessViews) {
|
|
|
|
Logger::err("D3D11DeviceContext::CSGetUnorderedAccessViews: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMSetRenderTargets(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumViews,
|
|
|
|
ID3D11RenderTargetView* const* ppRenderTargetViews,
|
|
|
|
ID3D11DepthStencilView* pDepthStencilView) {
|
2018-01-13 23:09:03 +01:00
|
|
|
// Optimization: If the number of draw and dispatch calls issued
|
|
|
|
// prior to the previous context flush is above a certain threshold,
|
|
|
|
// submit the current command buffer in order to keep the GPU busy.
|
2018-01-13 23:40:17 +01:00
|
|
|
// This also helps keep the command buffers at a reasonable size.
|
2018-01-13 23:09:03 +01:00
|
|
|
if (m_drawCount >= 500)
|
|
|
|
this->Flush();
|
|
|
|
|
2017-12-05 12:59:35 +01:00
|
|
|
for (UINT i = 0; i < m_state.om.renderTargetViews.size(); i++) {
|
2017-12-04 13:39:37 +01:00
|
|
|
D3D11RenderTargetView* view = nullptr;
|
2017-11-29 20:19:40 +01:00
|
|
|
|
2017-12-04 13:39:37 +01:00
|
|
|
if ((i < NumViews) && (ppRenderTargetViews[i] != nullptr))
|
|
|
|
view = static_cast<D3D11RenderTargetView*>(ppRenderTargetViews[i]);
|
2017-11-29 20:19:40 +01:00
|
|
|
|
2017-12-05 12:59:35 +01:00
|
|
|
m_state.om.renderTargetViews.at(i) = view;
|
2017-11-29 20:19:40 +01:00
|
|
|
}
|
|
|
|
|
2017-12-09 03:53:42 +01:00
|
|
|
m_state.om.depthStencilView = static_cast<D3D11DepthStencilView*>(pDepthStencilView);
|
|
|
|
|
2018-01-12 15:38:07 +01:00
|
|
|
// NOTE According to the Microsoft docs, we are supposed to
|
|
|
|
// unbind overlapping shader resource views. Since this comes
|
|
|
|
// with a large performance penalty we'll ignore this until an
|
|
|
|
// application actually relies on this behaviour.
|
2018-01-20 19:11:42 +01:00
|
|
|
DxvkRenderTargets attachments;
|
2017-11-29 20:19:40 +01:00
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
// D3D11 doesn't have the concept of a framebuffer object,
|
|
|
|
// so we'll just create a new one every time the render
|
|
|
|
// target bindings are updated. Set up the attachments.
|
2017-12-06 12:11:59 +01:00
|
|
|
if (ppRenderTargetViews != nullptr || pDepthStencilView != nullptr) {
|
|
|
|
for (UINT i = 0; i < m_state.om.renderTargetViews.size(); i++) {
|
|
|
|
if (m_state.om.renderTargetViews.at(i) != nullptr)
|
2018-01-11 12:23:55 +01:00
|
|
|
attachments.setColorTarget(i, m_state.om.renderTargetViews.at(i)->GetImageView());
|
2017-12-06 12:11:59 +01:00
|
|
|
}
|
|
|
|
|
2017-12-09 03:53:42 +01:00
|
|
|
if (m_state.om.depthStencilView != nullptr)
|
2018-01-11 12:23:55 +01:00
|
|
|
attachments.setDepthTarget(m_state.om.depthStencilView->GetImageView());
|
2017-11-29 20:19:40 +01:00
|
|
|
}
|
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
// Create and bind the framebuffer object to the context
|
|
|
|
EmitCs([attachments, dev = m_device] (DxvkContext* ctx) {
|
|
|
|
Rc<DxvkFramebuffer> framebuffer = nullptr;
|
|
|
|
if (attachments.hasAttachments())
|
|
|
|
framebuffer = dev->createFramebuffer(attachments);
|
|
|
|
ctx->bindFramebuffer(framebuffer);
|
|
|
|
});
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumRTVs,
|
|
|
|
ID3D11RenderTargetView* const* ppRenderTargetViews,
|
|
|
|
ID3D11DepthStencilView* pDepthStencilView,
|
|
|
|
UINT UAVStartSlot,
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
|
2017-11-29 20:19:40 +01:00
|
|
|
const UINT* pUAVInitialCounts) {
|
2018-01-12 15:38:07 +01:00
|
|
|
if (NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL)
|
|
|
|
OMSetRenderTargets(NumRTVs, ppRenderTargetViews, pDepthStencilView);
|
|
|
|
|
|
|
|
if (NumUAVs != D3D11_KEEP_UNORDERED_ACCESS_VIEWS) {
|
|
|
|
// UAVs are made available to all shader stages in
|
|
|
|
// the graphics pipeline even though this code may
|
|
|
|
// suggest that they are limited to the pixel shader.
|
|
|
|
// This behaviour is only required for FL_11_1.
|
|
|
|
BindUnorderedAccessViews(
|
|
|
|
DxbcProgramType::PixelShader,
|
|
|
|
m_state.ps.unorderedAccessViews,
|
|
|
|
UAVStartSlot, NumUAVs,
|
|
|
|
ppUnorderedAccessViews);
|
|
|
|
|
|
|
|
if (pUAVInitialCounts != nullptr) {
|
|
|
|
InitUnorderedAccessViewCounters(NumUAVs,
|
|
|
|
ppUnorderedAccessViews, pUAVInitialCounts);
|
|
|
|
}
|
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMSetBlendState(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11BlendState* pBlendState,
|
|
|
|
const FLOAT BlendFactor[4],
|
|
|
|
UINT SampleMask) {
|
2018-01-20 19:11:42 +01:00
|
|
|
Com<D3D11BlendState> blendState =
|
|
|
|
static_cast<D3D11BlendState*>(pBlendState);
|
2017-12-11 14:11:18 +01:00
|
|
|
|
|
|
|
if (m_state.om.cbState != blendState
|
|
|
|
|| m_state.om.sampleMask != SampleMask) {
|
|
|
|
m_state.om.cbState = blendState;
|
|
|
|
m_state.om.sampleMask = SampleMask;
|
|
|
|
|
|
|
|
if (blendState == nullptr)
|
|
|
|
blendState = m_defaultBlendState.ptr();
|
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
EmitCs([
|
|
|
|
cBlendState = std::move(blendState),
|
|
|
|
cSampleMask = SampleMask
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
cBlendState->BindToContext(ctx, cSampleMask);
|
|
|
|
});
|
2017-12-11 14:11:18 +01:00
|
|
|
}
|
|
|
|
|
2018-01-20 15:41:06 +01:00
|
|
|
if (BlendFactor != nullptr) {
|
2018-01-20 19:11:42 +01:00
|
|
|
bool updateBlendFactor = false;
|
2018-01-20 15:41:06 +01:00
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
for (uint32_t i = 0; i < 4; i++) {
|
|
|
|
updateBlendFactor |= m_state.om.blendFactor[i] != BlendFactor[i];
|
|
|
|
m_state.om.blendFactor[i] = BlendFactor[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updateBlendFactor) {
|
|
|
|
EmitCs([
|
|
|
|
cBlendConstants = DxvkBlendConstants {
|
|
|
|
BlendFactor[0], BlendFactor[1],
|
|
|
|
BlendFactor[2], BlendFactor[3] }
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->setBlendConstants(cBlendConstants);
|
|
|
|
});
|
|
|
|
}
|
2017-12-11 14:11:18 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMSetDepthStencilState(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DepthStencilState* pDepthStencilState,
|
|
|
|
UINT StencilRef) {
|
2018-01-20 19:11:42 +01:00
|
|
|
Com<D3D11DepthStencilState> depthStencilState =
|
|
|
|
static_cast<D3D11DepthStencilState*>(pDepthStencilState);
|
2017-12-11 14:11:18 +01:00
|
|
|
|
|
|
|
if (m_state.om.dsState != depthStencilState) {
|
|
|
|
m_state.om.dsState = depthStencilState;
|
|
|
|
|
|
|
|
if (depthStencilState == nullptr)
|
|
|
|
depthStencilState = m_defaultDepthStencilState.ptr();
|
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
EmitCs([cDepthStencilState = std::move(depthStencilState)]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
cDepthStencilState->BindToContext(ctx);
|
|
|
|
});
|
2017-12-11 14:11:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_state.om.stencilRef != StencilRef) {
|
|
|
|
m_state.om.stencilRef = StencilRef;
|
2018-01-20 19:11:42 +01:00
|
|
|
|
|
|
|
EmitCs([cStencilRef = StencilRef] (DxvkContext* ctx) {
|
|
|
|
ctx->setStencilReference(cStencilRef);
|
|
|
|
});
|
2017-12-11 14:11:18 +01:00
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMGetRenderTargets(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumViews,
|
|
|
|
ID3D11RenderTargetView** ppRenderTargetViews,
|
|
|
|
ID3D11DepthStencilView** ppDepthStencilView) {
|
2017-11-29 20:19:40 +01:00
|
|
|
if (ppRenderTargetViews != nullptr) {
|
|
|
|
for (UINT i = 0; i < NumViews; i++)
|
2017-12-05 12:59:35 +01:00
|
|
|
ppRenderTargetViews[i] = i < m_state.om.renderTargetViews.size()
|
|
|
|
? m_state.om.renderTargetViews.at(i).ref()
|
2017-11-29 20:19:40 +01:00
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:14:11 +01:00
|
|
|
if (ppDepthStencilView != nullptr)
|
|
|
|
*ppDepthStencilView = m_state.om.depthStencilView.ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMGetRenderTargetsAndUnorderedAccessViews(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumRTVs,
|
|
|
|
ID3D11RenderTargetView** ppRenderTargetViews,
|
|
|
|
ID3D11DepthStencilView** ppDepthStencilView,
|
|
|
|
UINT UAVStartSlot,
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView** ppUnorderedAccessViews) {
|
|
|
|
Logger::err("D3D11DeviceContext::OMGetRenderTargetsAndUnorderedAccessViews: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMGetBlendState(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11BlendState** ppBlendState,
|
|
|
|
FLOAT BlendFactor[4],
|
|
|
|
UINT* pSampleMask) {
|
2017-12-11 14:21:24 +01:00
|
|
|
if (ppBlendState != nullptr)
|
|
|
|
*ppBlendState = m_state.om.cbState.ref();
|
|
|
|
|
|
|
|
if (BlendFactor != nullptr)
|
|
|
|
std::memcpy(BlendFactor, m_state.om.blendFactor, sizeof(FLOAT) * 4);
|
|
|
|
|
|
|
|
if (pSampleMask != nullptr)
|
|
|
|
*pSampleMask = m_state.om.sampleMask;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::OMGetDepthStencilState(
|
2017-10-11 09:51:48 +02:00
|
|
|
ID3D11DepthStencilState** ppDepthStencilState,
|
|
|
|
UINT* pStencilRef) {
|
2017-12-11 14:21:24 +01:00
|
|
|
if (ppDepthStencilState != nullptr)
|
|
|
|
*ppDepthStencilState = m_state.om.dsState.ref();
|
|
|
|
|
|
|
|
if (pStencilRef != nullptr)
|
|
|
|
*pStencilRef = m_state.om.stencilRef;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSSetState(ID3D11RasterizerState* pRasterizerState) {
|
2018-01-20 19:11:42 +01:00
|
|
|
Com<D3D11RasterizerState> rasterizerState =
|
|
|
|
static_cast<D3D11RasterizerState*>(pRasterizerState);
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-06 13:16:54 +01:00
|
|
|
if (m_state.rs.state != rasterizerState) {
|
|
|
|
m_state.rs.state = rasterizerState;
|
|
|
|
|
2017-12-11 14:11:18 +01:00
|
|
|
if (rasterizerState == nullptr)
|
|
|
|
rasterizerState = m_defaultRasterizerState.ptr();
|
|
|
|
|
2018-01-20 19:11:42 +01:00
|
|
|
EmitCs([cRasterizerState = std::move(rasterizerState)]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
cRasterizerState->BindToContext(ctx);
|
|
|
|
});
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
// In D3D11, the rasterizer state defines
|
|
|
|
// whether the scissor test is enabled, so
|
|
|
|
// we have to update the scissor rectangles.
|
|
|
|
this->ApplyViewportState();
|
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSSetViewports(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumViewports,
|
|
|
|
const D3D11_VIEWPORT* pViewports) {
|
2017-12-06 12:11:59 +01:00
|
|
|
m_state.rs.numViewports = NumViewports;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < NumViewports; i++)
|
|
|
|
m_state.rs.viewports.at(i) = pViewports[i];
|
|
|
|
|
|
|
|
this->ApplyViewportState();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSSetScissorRects(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumRects,
|
|
|
|
const D3D11_RECT* pRects) {
|
2017-12-06 12:11:59 +01:00
|
|
|
m_state.rs.numScissors = NumRects;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < NumRects; i++)
|
|
|
|
m_state.rs.scissors.at(i) = pRects[i];
|
|
|
|
|
|
|
|
if (m_state.rs.state != nullptr) {
|
|
|
|
D3D11_RASTERIZER_DESC rsDesc;
|
|
|
|
m_state.rs.state->GetDesc(&rsDesc);
|
|
|
|
|
|
|
|
if (rsDesc.ScissorEnable)
|
|
|
|
this->ApplyViewportState();
|
|
|
|
}
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSGetState(ID3D11RasterizerState** ppRasterizerState) {
|
2017-12-11 14:21:24 +01:00
|
|
|
if (ppRasterizerState != nullptr)
|
|
|
|
*ppRasterizerState = m_state.rs.state.ref();
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSGetViewports(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT* pNumViewports,
|
|
|
|
D3D11_VIEWPORT* pViewports) {
|
2017-12-06 12:11:59 +01:00
|
|
|
if (pViewports != nullptr) {
|
|
|
|
for (uint32_t i = 0; i < *pNumViewports; i++) {
|
|
|
|
if (i < m_state.rs.numViewports) {
|
|
|
|
pViewports[i] = m_state.rs.viewports.at(i);
|
|
|
|
} else {
|
|
|
|
pViewports[i].TopLeftX = 0.0f;
|
|
|
|
pViewports[i].TopLeftY = 0.0f;
|
|
|
|
pViewports[i].Width = 0.0f;
|
|
|
|
pViewports[i].Height = 0.0f;
|
|
|
|
pViewports[i].MinDepth = 0.0f;
|
|
|
|
pViewports[i].MaxDepth = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pNumViewports = m_state.rs.numViewports;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::RSGetScissorRects(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT* pNumRects,
|
|
|
|
D3D11_RECT* pRects) {
|
2017-12-06 12:11:59 +01:00
|
|
|
if (pRects != nullptr) {
|
|
|
|
for (uint32_t i = 0; i < *pNumRects; i++) {
|
|
|
|
if (i < m_state.rs.numScissors) {
|
|
|
|
pRects[i] = m_state.rs.scissors.at(i);
|
|
|
|
} else {
|
|
|
|
pRects[i].left = 0;
|
|
|
|
pRects[i].top = 0;
|
|
|
|
pRects[i].right = 0;
|
|
|
|
pRects[i].bottom = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*pNumRects = m_state.rs.numScissors;
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::SOSetTargets(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppSOTargets,
|
|
|
|
const UINT* pOffsets) {
|
|
|
|
Logger::err("D3D11DeviceContext::SOSetTargets: Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
void STDMETHODCALLTYPE D3D11DeviceContext::SOGetTargets(
|
2017-10-11 09:51:48 +02:00
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer** ppSOTargets) {
|
|
|
|
Logger::err("D3D11DeviceContext::SOGetTargets: Not implemented");
|
|
|
|
}
|
|
|
|
|
2017-12-06 12:11:59 +01:00
|
|
|
|
2017-12-08 19:39:33 +01:00
|
|
|
void D3D11DeviceContext::BindConstantBuffers(
|
2017-12-08 22:30:41 +01:00
|
|
|
DxbcProgramType ShaderStage,
|
2017-12-20 17:37:46 +01:00
|
|
|
D3D11ConstantBufferBindings& Bindings,
|
2017-12-08 19:39:33 +01:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumBuffers,
|
|
|
|
ID3D11Buffer* const* ppConstantBuffers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
const uint32_t slotId = computeResourceSlotId(
|
|
|
|
ShaderStage, DxbcBindingType::ConstantBuffer,
|
|
|
|
StartSlot);
|
|
|
|
|
2017-12-08 19:39:33 +01:00
|
|
|
for (uint32_t i = 0; i < NumBuffers; i++) {
|
2017-12-20 17:37:46 +01:00
|
|
|
auto newBuffer = static_cast<D3D11Buffer*>(ppConstantBuffers[i]);
|
2017-12-08 19:39:33 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
if (Bindings[StartSlot + i] != newBuffer) {
|
|
|
|
Bindings[StartSlot + i] = newBuffer;
|
2017-12-08 19:39:33 +01:00
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([
|
|
|
|
cSlotId = slotId + i,
|
|
|
|
cSlice = newBuffer != nullptr
|
|
|
|
? newBuffer->GetBufferSlice()
|
|
|
|
: DxvkBufferSlice()
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceBuffer(cSlotId, cSlice);
|
|
|
|
});
|
2017-12-08 19:39:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-09 21:17:26 +01:00
|
|
|
void D3D11DeviceContext::BindSamplers(
|
|
|
|
DxbcProgramType ShaderStage,
|
2017-12-20 17:37:46 +01:00
|
|
|
D3D11SamplerBindings& Bindings,
|
2017-12-09 21:17:26 +01:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumSamplers,
|
|
|
|
ID3D11SamplerState* const* ppSamplers) {
|
2017-12-20 17:37:46 +01:00
|
|
|
const uint32_t slotId = computeResourceSlotId(
|
|
|
|
ShaderStage, DxbcBindingType::ImageSampler,
|
|
|
|
StartSlot);
|
|
|
|
|
2017-12-09 21:17:26 +01:00
|
|
|
for (uint32_t i = 0; i < NumSamplers; i++) {
|
2017-12-20 17:37:46 +01:00
|
|
|
auto sampler = static_cast<D3D11SamplerState*>(ppSamplers[i]);
|
2017-12-09 21:17:26 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
if (Bindings[StartSlot + i] != sampler) {
|
|
|
|
Bindings[StartSlot + i] = sampler;
|
2017-12-09 21:17:26 +01:00
|
|
|
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([
|
|
|
|
cSlotId = slotId + i,
|
|
|
|
cSampler = sampler != nullptr
|
|
|
|
? sampler->GetDXVKSampler()
|
|
|
|
: m_defaultSampler
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceSampler(cSlotId, cSampler);
|
|
|
|
});
|
2017-12-09 21:17:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-10 01:56:07 +01:00
|
|
|
void D3D11DeviceContext::BindShaderResources(
|
|
|
|
DxbcProgramType ShaderStage,
|
2017-12-20 17:37:46 +01:00
|
|
|
D3D11ShaderResourceBindings& Bindings,
|
2017-12-10 01:56:07 +01:00
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumResources,
|
|
|
|
ID3D11ShaderResourceView* const* ppResources) {
|
2017-12-20 17:37:46 +01:00
|
|
|
const uint32_t slotId = computeResourceSlotId(
|
|
|
|
ShaderStage, DxbcBindingType::ShaderResource,
|
|
|
|
StartSlot);
|
|
|
|
|
2017-12-10 01:56:07 +01:00
|
|
|
for (uint32_t i = 0; i < NumResources; i++) {
|
2017-12-20 17:37:46 +01:00
|
|
|
auto resView = static_cast<D3D11ShaderResourceView*>(ppResources[i]);
|
2017-12-10 01:56:07 +01:00
|
|
|
|
2017-12-20 17:37:46 +01:00
|
|
|
if (Bindings[StartSlot + i] != resView) {
|
|
|
|
Bindings[StartSlot + i] = resView;
|
2017-12-10 01:56:07 +01:00
|
|
|
|
|
|
|
if (resView != nullptr) {
|
|
|
|
// Figure out what we have to bind based on the resource type
|
|
|
|
if (resView->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cSlotId = slotId + i, cView = resView->GetBufferView()]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceTexelBuffer(cSlotId, cView);
|
|
|
|
});
|
2017-12-10 01:56:07 +01:00
|
|
|
} else {
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cSlotId = slotId + i, cView = resView->GetImageView()]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceImage(cSlotId, cView);
|
|
|
|
});
|
2017-12-10 01:56:07 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// When unbinding a resource, it doesn't really matter if
|
|
|
|
// the resource type is correct, so we'll just bind a null
|
|
|
|
// image to the given resource slot
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cSlotId = slotId + i] (DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceImage(cSlotId, nullptr);
|
|
|
|
});
|
2017-12-10 01:56:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-28 19:05:53 +01:00
|
|
|
void D3D11DeviceContext::BindUnorderedAccessViews(
|
|
|
|
DxbcProgramType ShaderStage,
|
|
|
|
D3D11UnorderedAccessBindings& Bindings,
|
|
|
|
UINT StartSlot,
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews) {
|
2018-01-11 17:12:39 +01:00
|
|
|
const uint32_t uavSlotId = computeResourceSlotId(
|
2017-12-28 19:05:53 +01:00
|
|
|
ShaderStage, DxbcBindingType::UnorderedAccessView,
|
|
|
|
StartSlot);
|
|
|
|
|
2018-01-11 17:12:39 +01:00
|
|
|
const uint32_t ctrSlotId = computeResourceSlotId(
|
|
|
|
ShaderStage, DxbcBindingType::UavCounter,
|
|
|
|
StartSlot);
|
|
|
|
|
2017-12-28 19:05:53 +01:00
|
|
|
for (uint32_t i = 0; i < NumUAVs; i++) {
|
|
|
|
auto uav = static_cast<D3D11UnorderedAccessView*>(ppUnorderedAccessViews[i]);
|
|
|
|
|
|
|
|
if (Bindings[StartSlot + i] != uav) {
|
|
|
|
Bindings[StartSlot + i] = uav;
|
|
|
|
|
|
|
|
if (uav != nullptr) {
|
|
|
|
// Figure out what we have to bind based on the resource type
|
|
|
|
if (uav->GetResourceType() == D3D11_RESOURCE_DIMENSION_BUFFER) {
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([
|
|
|
|
cUavSlotId = uavSlotId + i,
|
|
|
|
cCtrSlotId = ctrSlotId + i,
|
|
|
|
cUavBuffer = uav->GetBufferView(),
|
|
|
|
cCtrBuffer = uav->GetCounterSlice()
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceTexelBuffer(cUavSlotId, cUavBuffer);
|
|
|
|
ctx->bindResourceBuffer (cCtrSlotId, cCtrBuffer);
|
|
|
|
});
|
2017-12-28 19:05:53 +01:00
|
|
|
} else {
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cUavSlotId = uavSlotId + i, cUavImage = uav->GetImageView()]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceImage(cUavSlotId, cUavImage);
|
|
|
|
});
|
2017-12-28 19:05:53 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// When unbinding a resource, it doesn't really matter if
|
|
|
|
// the resource type is correct, so we'll just bind a null
|
|
|
|
// image to the given resource slot
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([cUavSlotId = uavSlotId + i, cCtrSlotId = ctrSlotId + i]
|
|
|
|
(DxvkContext* ctx) {
|
|
|
|
ctx->bindResourceTexelBuffer(cUavSlotId, nullptr);
|
|
|
|
ctx->bindResourceBuffer (cCtrSlotId, DxvkBufferSlice());
|
|
|
|
});
|
2017-12-28 19:05:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-11 12:23:55 +01:00
|
|
|
void D3D11DeviceContext::InitUnorderedAccessViewCounters(
|
|
|
|
UINT NumUAVs,
|
|
|
|
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
|
|
|
|
const UINT* pUAVInitialCounts) {
|
|
|
|
for (uint32_t i = 0; i < NumUAVs; i++) {
|
|
|
|
auto uav = static_cast<D3D11UnorderedAccessView*>(ppUnorderedAccessViews[i]);
|
|
|
|
|
|
|
|
if (uav != nullptr) {
|
|
|
|
const DxvkBufferSlice counterSlice = uav->GetCounterSlice();
|
|
|
|
const D3D11UavCounter counterValue = { pUAVInitialCounts[i] };
|
|
|
|
|
2018-01-18 18:33:13 +01:00
|
|
|
if (counterSlice.defined()
|
2018-01-11 17:12:39 +01:00
|
|
|
&& counterValue.atomicCtr != 0xFFFFFFFFu) {
|
2018-01-20 18:54:37 +01:00
|
|
|
EmitCs([counterSlice, counterValue] (DxvkContext* ctx) {
|
|
|
|
ctx->updateBuffer(
|
|
|
|
counterSlice.buffer(),
|
|
|
|
counterSlice.offset(),
|
|
|
|
counterSlice.length(),
|
|
|
|
&counterValue);
|
|
|
|
});
|
2018-01-11 12:23:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-06 12:11:59 +01:00
|
|
|
void D3D11DeviceContext::ApplyViewportState() {
|
|
|
|
// We cannot set less than one viewport in Vulkan, and
|
|
|
|
// rendering with no active viewport is illegal anyway.
|
|
|
|
if (m_state.rs.numViewports == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::array<VkViewport, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> viewports;
|
|
|
|
std::array<VkRect2D, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> scissors;
|
|
|
|
|
2017-12-08 22:30:41 +01:00
|
|
|
// D3D11's coordinate system has its origin in the bottom left,
|
|
|
|
// but the viewport coordinates are aligned to the top-left
|
|
|
|
// corner so we can get away with flipping the viewport.
|
2017-12-06 12:11:59 +01:00
|
|
|
for (uint32_t i = 0; i < m_state.rs.numViewports; i++) {
|
|
|
|
const D3D11_VIEWPORT& vp = m_state.rs.viewports.at(i);
|
|
|
|
|
|
|
|
viewports.at(i) = VkViewport {
|
2018-01-05 16:53:12 +01:00
|
|
|
vp.TopLeftX, vp.Height + vp.TopLeftY,
|
2017-12-07 18:38:54 +01:00
|
|
|
vp.Width, -vp.Height,
|
|
|
|
vp.MinDepth, vp.MaxDepth,
|
2017-12-06 12:11:59 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scissor rectangles. Vulkan does not provide an easy way
|
|
|
|
// to disable the scissor test, so we'll have to set scissor
|
|
|
|
// rects that are at least as large as the framebuffer.
|
|
|
|
bool enableScissorTest = false;
|
|
|
|
|
|
|
|
if (m_state.rs.state != nullptr) {
|
|
|
|
D3D11_RASTERIZER_DESC rsDesc;
|
|
|
|
m_state.rs.state->GetDesc(&rsDesc);
|
|
|
|
enableScissorTest = rsDesc.ScissorEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < m_state.rs.numViewports; i++) {
|
|
|
|
// TODO D3D11 docs aren't clear about what should happen
|
|
|
|
// when there are undefined scissor rects for a viewport.
|
|
|
|
// Figure out what it does on Windows.
|
|
|
|
if (enableScissorTest && (i < m_state.rs.numScissors)) {
|
|
|
|
const D3D11_RECT& sr = m_state.rs.scissors.at(i);
|
|
|
|
|
|
|
|
scissors.at(i) = VkRect2D {
|
|
|
|
VkOffset2D { sr.left, sr.top },
|
|
|
|
VkExtent2D {
|
|
|
|
static_cast<uint32_t>(sr.right - sr.left),
|
|
|
|
static_cast<uint32_t>(sr.bottom - sr.top) } };
|
|
|
|
} else {
|
|
|
|
scissors.at(i) = VkRect2D {
|
|
|
|
VkOffset2D { 0, 0 },
|
|
|
|
VkExtent2D {
|
|
|
|
D3D11_VIEWPORT_BOUNDS_MAX,
|
|
|
|
D3D11_VIEWPORT_BOUNDS_MAX } };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-20 19:30:31 +01:00
|
|
|
EmitCs([
|
|
|
|
cViewportCount = m_state.rs.numViewports,
|
|
|
|
cViewports = viewports,
|
|
|
|
cScissors = scissors
|
|
|
|
] (DxvkContext* ctx) {
|
|
|
|
ctx->setViewports(
|
|
|
|
cViewportCount,
|
|
|
|
cViewports.data(),
|
|
|
|
cScissors.data());
|
|
|
|
});
|
2017-12-06 12:11:59 +01:00
|
|
|
}
|
|
|
|
|
2018-01-10 19:07:55 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-01-23 16:43:55 +01:00
|
|
|
|
|
|
|
DxvkDataSlice D3D11DeviceContext::AllocUpdateBufferSlice(size_t Size) {
|
|
|
|
constexpr size_t UpdateBufferSize = 4 * 1024 * 1024;
|
|
|
|
|
|
|
|
if (Size >= UpdateBufferSize) {
|
|
|
|
Rc<DxvkDataBuffer> buffer = new DxvkDataBuffer(Size);
|
|
|
|
return buffer->alloc(Size);
|
|
|
|
} else {
|
|
|
|
if (m_updateBuffer == nullptr)
|
|
|
|
m_updateBuffer = new DxvkDataBuffer(Size);
|
|
|
|
|
|
|
|
DxvkDataSlice slice = m_updateBuffer->alloc(Size);
|
|
|
|
|
|
|
|
if (slice.ptr() == nullptr) {
|
|
|
|
m_updateBuffer = new DxvkDataBuffer(Size);
|
|
|
|
slice = m_updateBuffer->alloc(Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return slice;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-11 09:51:48 +02:00
|
|
|
}
|