Windows fixes

This commit is contained in:
Jack Andersen
2016-02-24 10:52:31 -10:00
parent 478b05ceb7
commit d657f3c8f8
4 changed files with 49 additions and 57 deletions

View File

@@ -766,6 +766,7 @@ struct D3D11CommandQueue : IGraphicsCommandQueue
m_initcv.wait(m_initlk);
m_initlk.unlock();
ThrowIfFailed(ctx->m_dev->CreateDeferredContext1(0, &m_deferredCtx));
m_deferredCtx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
void stopRenderer()
@@ -846,14 +847,6 @@ struct D3D11CommandQueue : IGraphicsCommandQueue
m_deferredCtx->ClearDepthStencilView(m_boundTarget->m_dsv.Get(), D3D11_CLEAR_DEPTH, 1.0, 0);
}
void setDrawPrimitive(Primitive prim)
{
if (prim == Primitive::Triangles)
m_deferredCtx->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
else if (prim == Primitive::TriStrips)
m_deferredCtx->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
void draw(size_t start, size_t count)
{
m_deferredCtx->Draw(count, start);
@@ -958,6 +951,7 @@ class D3D11DataFactory : public ID3DDataFactory
std::unordered_set<D3D11Data*> m_committedData;
std::mutex m_committedMutex;
std::unordered_set<D3D11Data*> m_deletedData;
uint32_t m_sampleCount;
void destroyData(IGraphicsData* d)
{
@@ -996,8 +990,8 @@ class D3D11DataFactory : public ID3DDataFactory
}
public:
D3D11DataFactory(IGraphicsContext* parent, D3D11Context* ctx)
: m_parent(parent), m_ctx(ctx)
D3D11DataFactory(IGraphicsContext* parent, D3D11Context* ctx, uint32_t sampleCount)
: m_parent(parent), m_ctx(ctx), m_sampleCount(sampleCount)
{}
~D3D11DataFactory() {destroyAllData();}
@@ -1035,12 +1029,12 @@ public:
GraphicsDataToken
newStaticTextureNoContext(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz, ITextureS** texOut)
const void* data, size_t sz, ITextureS*& texOut)
{
D3D11TextureS* retval = new D3D11TextureS(m_ctx, width, height, mips, fmt, data, sz);
D3D11Data* tokData = new struct D3D11Data();
tokData->m_STexs.emplace_back(retval);
*texOut = retval;
texOut = retval;
std::unique_lock<std::mutex> lk(m_committedMutex);
m_committedData.insert(tokData);
@@ -1067,10 +1061,10 @@ public:
return retval;
}
ITextureR* newRenderTexture(size_t width, size_t height, size_t samples)
ITextureR* newRenderTexture(size_t width, size_t height)
{
D3D11CommandQueue* q = static_cast<D3D11CommandQueue*>(m_parent->getCommandQueue());
D3D11TextureR* retval = new D3D11TextureR(m_ctx, width, height, samples);
D3D11TextureR* retval = new D3D11TextureR(m_ctx, width, height, m_sampleCount);
if (!m_deferredData)
m_deferredData = new struct D3D11Data();
static_cast<D3D11Data*>(m_deferredData)->m_RTexs.emplace_back(retval);
@@ -1216,9 +1210,9 @@ IGraphicsCommandQueue* _NewD3D11CommandQueue(D3D11Context* ctx, D3D11Context::Wi
return new D3D11CommandQueue(ctx, windowCtx, parent);
}
IGraphicsDataFactory* _NewD3D11DataFactory(D3D11Context* ctx, IGraphicsContext* parent)
IGraphicsDataFactory* _NewD3D11DataFactory(D3D11Context* ctx, IGraphicsContext* parent, uint32_t sampleCount)
{
return new D3D11DataFactory(parent, ctx);
return new D3D11DataFactory(parent, ctx, sampleCount);
}
}

View File

@@ -981,6 +981,7 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
ThrowIfFailed(m_ctx->m_qalloc[m_fillBuf]->Reset());
ThrowIfFailed(m_cmdList->Reset(m_ctx->m_qalloc[m_fillBuf].Get(), nullptr));
m_cmdList->SetGraphicsRootSignature(m_ctx->m_rs.Get());
m_cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
void resetDynamicCommandList()
@@ -1027,6 +1028,7 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
nullptr, __uuidof(ID3D12GraphicsCommandList), &m_cmdList));
m_renderFenceHandle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
m_cmdList->SetGraphicsRootSignature(m_ctx->m_rs.Get());
m_cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
ThrowIfFailed(ctx->m_dev->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence), &m_dynamicBufFence));
m_dynamicBufFenceHandle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
@@ -1131,14 +1133,6 @@ struct D3D12CommandQueue : IGraphicsCommandQueue
}
}
void setDrawPrimitive(Primitive prim)
{
if (prim == Primitive::Triangles)
m_cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
else if (prim == Primitive::TriStrips)
m_cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
}
void draw(size_t start, size_t count)
{
m_cmdList->DrawInstanced(count, 1, start, 0);
@@ -1317,6 +1311,7 @@ class D3D12DataFactory : public ID3DDataFactory
struct D3D12Context* m_ctx;
std::unordered_set<D3D12Data*> m_committedData;
std::mutex m_committedMutex;
uint32_t m_sampleCount;
void destroyData(IGraphicsData* d)
{
@@ -1334,8 +1329,8 @@ class D3D12DataFactory : public ID3DDataFactory
m_committedData.clear();
}
public:
D3D12DataFactory(IGraphicsContext* parent, D3D12Context* ctx)
: m_parent(parent), m_ctx(ctx)
D3D12DataFactory(IGraphicsContext* parent, D3D12Context* ctx, uint32_t sampleCount)
: m_parent(parent), m_ctx(ctx), m_sampleCount(sampleCount)
{
CD3DX12_DESCRIPTOR_RANGE ranges[] =
{
@@ -1391,12 +1386,12 @@ public:
GraphicsDataToken
newStaticTextureNoContext(size_t width, size_t height, size_t mips, TextureFormat fmt,
const void* data, size_t sz, ITextureS** texOut)
const void* data, size_t sz, ITextureS*& texOut)
{
D3D12TextureS* retval = new D3D12TextureS(m_ctx, width, height, mips, fmt, data, sz);
D3D12Data* tokData = new struct D3D12Data();
tokData->m_STexs.emplace_back(retval);
*texOut = retval;
texOut = retval;
/* Create heap */
D3D12_RESOURCE_ALLOCATION_INFO texAllocInfo =
@@ -1451,10 +1446,10 @@ public:
return retval;
}
ITextureR* newRenderTexture(size_t width, size_t height, size_t samples)
ITextureR* newRenderTexture(size_t width, size_t height)
{
D3D12CommandQueue* q = static_cast<D3D12CommandQueue*>(m_parent->getCommandQueue());
D3D12TextureR* retval = new D3D12TextureR(m_ctx, q, width, height, samples);
D3D12TextureR* retval = new D3D12TextureR(m_ctx, q, width, height, m_sampleCount);
if (!m_deferredData)
m_deferredData = new struct D3D12Data();
static_cast<D3D12Data*>(m_deferredData)->m_RTexs.emplace_back(retval);
@@ -1724,9 +1719,9 @@ IGraphicsCommandQueue* _NewD3D12CommandQueue(D3D12Context* ctx, D3D12Context::Wi
return new struct D3D12CommandQueue(ctx, windowCtx, parent, cmdQueueOut);
}
IGraphicsDataFactory* _NewD3D12DataFactory(D3D12Context* ctx, IGraphicsContext* parent)
IGraphicsDataFactory* _NewD3D12DataFactory(D3D12Context* ctx, IGraphicsContext* parent, uint32_t sampleCount)
{
return new D3D12DataFactory(parent, ctx);
return new D3D12DataFactory(parent, ctx, sampleCount);
}
}