Fix macOS and Windows builds

This commit is contained in:
Phillip Stephens 2019-06-30 20:13:12 -07:00
parent c5f8a11850
commit 35732d33f5
4 changed files with 37 additions and 36 deletions

View File

@ -41,10 +41,9 @@ public:
ObjToken<ITextureSA> newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips, ObjToken<ITextureSA> newStaticArrayTexture(size_t width, size_t height, size_t layers, size_t mips,
TextureFormat fmt, TextureClampMode clampMode, const void* data, TextureFormat fmt, TextureClampMode clampMode, const void* data,
size_t sz); size_t sz);
ObjToken<ITextureD> newDynamicTexture(size_t width, size_t height, TextureFormat fmt, ObjToken<ITextureD> newDynamicTexture(size_t width, size_t height, TextureFormat fmt, TextureClampMode clampMode);
TextureClampMode clampMode); ObjToken<ITextureR> newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, size_t colorBindCount,
ObjToken<ITextureR> newRenderTexture(size_t width, size_t height, TextureClampMode clampMode, size_t depthBindCount);
size_t colorBindCount, size_t depthBindCount);
ObjToken<ITextureCubeR> newCubeRenderTexture(size_t width, size_t mips); ObjToken<ITextureCubeR> newCubeRenderTexture(size_t width, size_t mips);
ObjToken<IShaderStage> newShaderStage(const uint8_t* data, size_t size, PipelineStage stage); ObjToken<IShaderStage> newShaderStage(const uint8_t* data, size_t size, PipelineStage stage);
@ -52,14 +51,15 @@ public:
ObjToken<IShaderPipeline> newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment, ObjToken<IShaderPipeline> newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment,
ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control, ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control,
ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt, ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt,
const AdditionalPipelineInfo& additionalInfo); const AdditionalPipelineInfo& additionalInfo, bool asynchronous = true);
ObjToken<IShaderDataBinding> newShaderDataBinding( ObjToken<IShaderDataBinding>
const ObjToken<IShaderPipeline>& pipeline, const ObjToken<IGraphicsBuffer>& vbo, newShaderDataBinding(const ObjToken<IShaderPipeline>& pipeline, const ObjToken<IGraphicsBuffer>& vbo,
const ObjToken<IGraphicsBuffer>& instVbo, const ObjToken<IGraphicsBuffer>& ibo, size_t ubufCount, const ObjToken<IGraphicsBuffer>& instVbo, const ObjToken<IGraphicsBuffer>& ibo,
const ObjToken<IGraphicsBuffer>* ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, size_t ubufCount, const ObjToken<IGraphicsBuffer>* ubufs, const PipelineStage* ubufStages,
const size_t* ubufSizes, size_t texCount, const ObjToken<ITexture>* texs, const int* bindIdxs, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount,
const bool* bindDepth, size_t baseVert = 0, size_t baseInst = 0); const ObjToken<ITexture>* texs, const int* bindIdxs, const bool* bindDepth,
size_t baseVert = 0, size_t baseInst = 0);
}; };
static std::vector<uint8_t> CompileHLSL(const char* source, PipelineStage stage); static std::vector<uint8_t> CompileHLSL(const char* source, PipelineStage stage);

View File

@ -40,7 +40,7 @@ public:
ObjToken<IShaderPipeline> newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment, ObjToken<IShaderPipeline> newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment,
ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control, ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control,
ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt, ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt,
const AdditionalPipelineInfo& additionalInfo); const AdditionalPipelineInfo& additionalInfo, bool asynchronous = true);
ObjToken<IShaderDataBinding> newShaderDataBinding( ObjToken<IShaderDataBinding> newShaderDataBinding(
const ObjToken<IShaderPipeline>& pipeline, const ObjToken<IGraphicsBuffer>& vbo, const ObjToken<IShaderPipeline>& pipeline, const ObjToken<IGraphicsBuffer>& vbo,

View File

@ -433,8 +433,8 @@ class D3D11TextureCubeR : public GraphicsDataNode<ITextureCubeR> {
void Setup(D3D11Context* ctx) { void Setup(D3D11Context* ctx) {
CD3D11_TEXTURE2D_DESC colorDesc(ctx->m_fbFormat, m_width, m_width, 6, 1, CD3D11_TEXTURE2D_DESC colorDesc(ctx->m_fbFormat, m_width, m_width, 6, 1,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_DEFAULT, 0, 1, 0,
D3D11_USAGE_DEFAULT, 0, 1, 0, D3D11_RESOURCE_MISC_TEXTURECUBE); D3D11_RESOURCE_MISC_TEXTURECUBE);
ThrowIfFailed(ctx->m_dev->CreateTexture2D(&colorDesc, nullptr, &m_colorTex)); ThrowIfFailed(ctx->m_dev->CreateTexture2D(&colorDesc, nullptr, &m_colorTex));
CD3D11_TEXTURE2D_DESC depthDesc(DXGI_FORMAT_D32_FLOAT, m_width, m_width, 6, 1, D3D11_BIND_DEPTH_STENCIL, CD3D11_TEXTURE2D_DESC depthDesc(DXGI_FORMAT_D32_FLOAT, m_width, m_width, 6, 1, D3D11_BIND_DEPTH_STENCIL,
D3D11_USAGE_DEFAULT, 0, 1, 0, D3D11_RESOURCE_MISC_TEXTURECUBE); D3D11_USAGE_DEFAULT, 0, 1, 0, D3D11_RESOURCE_MISC_TEXTURECUBE);
@ -448,15 +448,13 @@ class D3D11TextureCubeR : public GraphicsDataNode<ITextureCubeR> {
ThrowIfFailed(ctx->m_dev->CreateRenderTargetView(m_colorTex.Get(), &rtvDesc, &m_rtv[i])); ThrowIfFailed(ctx->m_dev->CreateRenderTargetView(m_colorTex.Get(), &rtvDesc, &m_rtv[i]));
CD3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc(m_depthTex.Get(), dsvDim, DXGI_FORMAT_D32_FLOAT, 0, i); CD3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc(m_depthTex.Get(), dsvDim, DXGI_FORMAT_D32_FLOAT, 0, i);
ThrowIfFailed(ctx->m_dev->CreateDepthStencilView(m_depthTex.Get(), &dsvDesc, &m_dsv[i])); ThrowIfFailed(ctx->m_dev->CreateDepthStencilView(m_depthTex.Get(), &dsvDesc, &m_dsv[i]));
CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(D3D11_SRV_DIMENSION_TEXTURE2DARRAY, CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(D3D11_SRV_DIMENSION_TEXTURE2DARRAY, ctx->m_fbFormat, 0, 1, i, 1);
ctx->m_fbFormat, 0, 1, i, 1);
ThrowIfFailed(ctx->m_dev->CreateShaderResourceView(m_colorTex.Get(), &srvDesc, &m_srv[i])); ThrowIfFailed(ctx->m_dev->CreateShaderResourceView(m_colorTex.Get(), &srvDesc, &m_srv[i]));
} }
CD3D11_TEXTURE2D_DESC colorBindDesc(ctx->m_fbFormat, m_width, m_width, 6, m_mipCount, CD3D11_TEXTURE2D_DESC colorBindDesc(ctx->m_fbFormat, m_width, m_width, 6, m_mipCount,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_DEFAULT, 0,
D3D11_USAGE_DEFAULT, 0, 1, 0, 1, 0, D3D11_RESOURCE_MISC_TEXTURECUBE | D3D11_RESOURCE_MISC_GENERATE_MIPS);
D3D11_RESOURCE_MISC_TEXTURECUBE | D3D11_RESOURCE_MISC_GENERATE_MIPS);
ThrowIfFailed(ctx->m_dev->CreateTexture2D(&colorBindDesc, nullptr, &m_colorBindTex)); ThrowIfFailed(ctx->m_dev->CreateTexture2D(&colorBindDesc, nullptr, &m_colorBindTex));
for (int i = 0; i < 6; ++i) { for (int i = 0; i < 6; ++i) {
CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(m_colorBindTex.Get(), rtvDim, ctx->m_fbFormat, 0, i); CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(m_colorBindTex.Get(), rtvDim, ctx->m_fbFormat, 0, i);
@ -468,9 +466,7 @@ class D3D11TextureCubeR : public GraphicsDataNode<ITextureCubeR> {
} }
D3D11TextureCubeR(const boo::ObjToken<BaseGraphicsData>& parent, D3D11Context* ctx, size_t width, size_t mips) D3D11TextureCubeR(const boo::ObjToken<BaseGraphicsData>& parent, D3D11Context* ctx, size_t width, size_t mips)
: GraphicsDataNode<ITextureCubeR>(parent) : GraphicsDataNode<ITextureCubeR>(parent), m_width(width), m_mipCount(mips) {
, m_width(width)
, m_mipCount(mips) {
Setup(ctx); Setup(ctx);
} }
@ -734,6 +730,7 @@ public:
ctx->IASetInputLayout(m_inLayout.Get()); ctx->IASetInputLayout(m_inLayout.Get());
ctx->IASetPrimitiveTopology(m_topology); ctx->IASetPrimitiveTopology(m_topology);
} }
bool isReady() const { return true; }
}; };
struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> { struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> {
@ -1047,7 +1044,8 @@ struct D3D11CommandQueue : IGraphicsCommandQueue {
boundHeight = ctarget->m_width; boundHeight = ctarget->m_width;
break; break;
} }
default: break; default:
break;
} }
D3D11_VIEWPORT vp = {FLOAT(rect.location[0]), D3D11_VIEWPORT vp = {FLOAT(rect.location[0]),
FLOAT(boundHeight - rect.location[1] - rect.size[1]), FLOAT(boundHeight - rect.location[1] - rect.size[1]),
@ -1074,7 +1072,8 @@ struct D3D11CommandQueue : IGraphicsCommandQueue {
boundHeight = ctarget->m_width; boundHeight = ctarget->m_width;
break; break;
} }
default: break; default:
break;
} }
D3D11_RECT d3drect = {LONG(rect.location[0]), LONG(boundHeight - rect.location[1] - rect.size[1]), D3D11_RECT d3drect = {LONG(rect.location[0]), LONG(boundHeight - rect.location[1] - rect.size[1]),
LONG(rect.location[0] + rect.size[0]), LONG(boundHeight - rect.location[1])}; LONG(rect.location[0] + rect.size[0]), LONG(boundHeight - rect.location[1])};
@ -1128,7 +1127,8 @@ struct D3D11CommandQueue : IGraphicsCommandQueue {
m_deferredCtx->ClearDepthStencilView(ctarget->m_dsv[m_boundFace].Get(), D3D11_CLEAR_DEPTH, 0.0f, 0); m_deferredCtx->ClearDepthStencilView(ctarget->m_dsv[m_boundFace].Get(), D3D11_CLEAR_DEPTH, 0.0f, 0);
break; break;
} }
default: break; default:
break;
} }
} }
@ -1329,6 +1329,8 @@ public:
maxPatchSizeOut = 32; maxPatchSizeOut = 32;
return true; return true;
} }
void waitUntilShadersReady() {}
bool areShadersReady() { return true; }
}; };
void D3D11CommandQueue::generateMipmaps(const ObjToken<ITextureCubeR>& tex) { void D3D11CommandQueue::generateMipmaps(const ObjToken<ITextureCubeR>& tex) {
@ -1341,12 +1343,7 @@ void D3D11CommandQueue::generateMipmaps(const ObjToken<ITextureCubeR>& tex) {
UINT offsets[] = {0}; UINT offsets[] = {0};
m_deferredCtx->IASetVertexBuffers(0, 1, buffers, strides, offsets); m_deferredCtx->IASetVertexBuffers(0, 1, buffers, strides, offsets);
D3D11_VIEWPORT vp = {0.f, D3D11_VIEWPORT vp = {0.f, 0.f, FLOAT(ctex->m_width), FLOAT(ctex->m_width), 0.f, 1.f};
0.f,
FLOAT(ctex->m_width),
FLOAT(ctex->m_width),
0.f,
1.f};
m_deferredCtx->RSSetViewports(1, &vp); m_deferredCtx->RSSetViewports(1, &vp);
D3D11_RECT d3drect = {0, 0, LONG(ctex->m_width), LONG(ctex->m_width)}; D3D11_RECT d3drect = {0, 0, LONG(ctex->m_width), LONG(ctex->m_width)};
@ -1422,10 +1419,11 @@ boo::ObjToken<IShaderStage> D3D11DataFactory::Context::newShaderStage(const uint
return {new D3D11ShaderStage(m_data, factory.m_ctx, data, size, stage)}; return {new D3D11ShaderStage(m_data, factory.m_ctx, data, size, stage)};
} }
boo::ObjToken<IShaderPipeline> D3D11DataFactory::Context::newShaderPipeline( boo::ObjToken<IShaderPipeline>
ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment, ObjToken<IShaderStage> geometry, D3D11DataFactory::Context::newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment,
ObjToken<IShaderStage> control, ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt, ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control,
const AdditionalPipelineInfo& additionalInfo) { ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt,
const AdditionalPipelineInfo& additionalInfo, bool asynchronous) {
D3D11DataFactoryImpl& factory = static_cast<D3D11DataFactoryImpl&>(m_parent); D3D11DataFactoryImpl& factory = static_cast<D3D11DataFactoryImpl&>(m_parent);
struct D3D11Context* ctx = factory.m_ctx; struct D3D11Context* ctx = factory.m_ctx;
return { return {

View File

@ -148,6 +148,9 @@ public:
maxPatchSize = 32; maxPatchSize = 32;
return m_hasTessellation; return m_hasTessellation;
} }
void waitUntilShadersReady() {}
bool areShadersReady() const { return true; }
}; };
#define MTL_STATIC MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeManaged #define MTL_STATIC MTLResourceCPUCacheModeWriteCombined|MTLResourceStorageModeManaged
@ -1948,7 +1951,7 @@ ObjToken<IShaderPipeline>
MetalDataFactory::Context::newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment, MetalDataFactory::Context::newShaderPipeline(ObjToken<IShaderStage> vertex, ObjToken<IShaderStage> fragment,
ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control, ObjToken<IShaderStage> geometry, ObjToken<IShaderStage> control,
ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt, ObjToken<IShaderStage> evaluation, const VertexFormatInfo& vtxFmt,
const AdditionalPipelineInfo& additionalInfo) { const AdditionalPipelineInfo& additionalInfo, bool asynchronous) {
@autoreleasepool { @autoreleasepool {
MetalDataFactoryImpl& factory = static_cast<MetalDataFactoryImpl&>(m_parent); MetalDataFactoryImpl& factory = static_cast<MetalDataFactoryImpl&>(m_parent);