Fix Windows compilation using GN and clang-cl.
This includes a bunch of fixes for clang warnings in Windows specific code that was only compiled by MSVC previously. This also tidies up some BUILD.gn issues on Windows.
This commit is contained in:
parent
3bb0bb940e
commit
5b61abce09
3
BUILD.gn
3
BUILD.gn
|
@ -356,6 +356,7 @@ source_set("libdawn_native_sources") {
|
|||
libs += [
|
||||
"d3d12.lib",
|
||||
"dxgi.lib",
|
||||
"dxguid.lib",
|
||||
"d3dcompiler.lib",
|
||||
]
|
||||
sources += [
|
||||
|
@ -751,7 +752,7 @@ test("dawn_unittests") {
|
|||
]
|
||||
|
||||
if (dawn_enable_d3d12) {
|
||||
sources += [ "src/tests/unittests/d3d12CopySplitTests.cpp" ]
|
||||
sources += [ "src/tests/unittests/d3d12/CopySplitTests.cpp" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
// (resp. false) to help it generate code that leads to better branch prediction.
|
||||
// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
|
||||
|
||||
// Clang and GCC
|
||||
#if defined(__GNUC__)
|
||||
// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# if defined(__clang__)
|
||||
# define DAWN_COMPILER_CLANG
|
||||
# else
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace dawn_native {
|
|||
mDepthStencilAttachmentSet(builder->mDepthStencilAttachmentSet),
|
||||
mDepthStencilAttachment(builder->mDepthStencilAttachment),
|
||||
mWidth(builder->mWidth),
|
||||
mHeight(builder->mHeight) {
|
||||
mHeight(builder->mHeight),
|
||||
mDevice(builder->GetDevice()) {
|
||||
}
|
||||
|
||||
std::bitset<kMaxColorAttachments> RenderPassDescriptorBase::GetColorAttachmentMask() const {
|
||||
|
@ -77,6 +78,10 @@ namespace dawn_native {
|
|||
return mHeight;
|
||||
}
|
||||
|
||||
DeviceBase* RenderPassDescriptorBase::GetDevice() const {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
// RenderPassDescriptorBuilder
|
||||
|
||||
RenderPassDescriptorBuilder::RenderPassDescriptorBuilder(DeviceBase* device) : Builder(device) {
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace dawn_native {
|
|||
uint32_t GetWidth() const;
|
||||
uint32_t GetHeight() const;
|
||||
|
||||
DeviceBase* GetDevice() const;
|
||||
|
||||
private:
|
||||
std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
|
||||
std::array<RenderPassColorAttachmentInfo, kMaxColorAttachments> mColorAttachments;
|
||||
|
@ -70,6 +72,8 @@ namespace dawn_native {
|
|||
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
|
||||
DeviceBase* mDevice;
|
||||
};
|
||||
|
||||
class RenderPassDescriptorBuilder : public Builder<RenderPassDescriptorBase> {
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
BindGroup::BindGroup(Device* device, BindGroupBuilder* builder)
|
||||
: BindGroupBase(builder), mDevice(device) {
|
||||
BindGroup::BindGroup(BindGroupBuilder* builder) : BindGroupBase(builder) {
|
||||
}
|
||||
|
||||
void BindGroup::RecordDescriptors(const DescriptorHeapHandle& cbvUavSrvHeapStart,
|
||||
|
@ -43,7 +42,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
const auto& bindingOffsets = bgl->GetBindingOffsets();
|
||||
|
||||
auto d3d12Device = mDevice->GetD3D12Device();
|
||||
auto d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
|
||||
for (uint32_t binding : IterateBitSet(layout.mask)) {
|
||||
switch (layout.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class BindGroup : public BindGroupBase {
|
||||
public:
|
||||
BindGroup(Device* device, BindGroupBuilder* builder);
|
||||
BindGroup(BindGroupBuilder* builder);
|
||||
|
||||
void RecordDescriptors(const DescriptorHeapHandle& cbvSrvUavHeapStart,
|
||||
uint32_t* cbvUavSrvHeapOffset,
|
||||
|
@ -39,11 +39,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
uint64_t GetHeapSerial() const;
|
||||
|
||||
private:
|
||||
Device* mDevice;
|
||||
uint32_t mCbvUavSrvHeapOffset;
|
||||
uint32_t mSamplerHeapOffset;
|
||||
uint32_t mCbvUavSrvCount = 0;
|
||||
uint32_t mSamplerCount = 0;
|
||||
uint64_t mHeapSerial = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
ComPtr<ID3DBlob> compiledShader;
|
||||
ComPtr<ID3DBlob> errors;
|
||||
|
||||
if (FAILED(D3DCompile(hlslSource.c_str(), hlslSource.length(), nullptr, {nullptr}, nullptr,
|
||||
if (FAILED(D3DCompile(hlslSource.c_str(), hlslSource.length(), nullptr, nullptr, nullptr,
|
||||
entryPoint.c_str(), "cs_5_1", compileFlags, 0, &compiledShader,
|
||||
&errors))) {
|
||||
printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
|
||||
|
|
|
@ -76,8 +76,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
return desc;
|
||||
}
|
||||
|
||||
DepthStencilState::DepthStencilState(Device* device, DepthStencilStateBuilder* builder)
|
||||
: DepthStencilStateBase(builder), mDevice(device) {
|
||||
DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
|
||||
: DepthStencilStateBase(builder) {
|
||||
mDepthStencilDescriptor.DepthEnable = TRUE;
|
||||
mDepthStencilDescriptor.DepthWriteMask =
|
||||
GetDepth().depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO;
|
||||
|
|
|
@ -25,12 +25,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class DepthStencilState : public DepthStencilStateBase {
|
||||
public:
|
||||
DepthStencilState(Device* device, DepthStencilStateBuilder* builder);
|
||||
DepthStencilState(DepthStencilStateBuilder* builder);
|
||||
|
||||
const D3D12_DEPTH_STENCIL_DESC& GetD3D12DepthStencilDescriptor() const;
|
||||
|
||||
private:
|
||||
Device* mDevice;
|
||||
D3D12_DEPTH_STENCIL_DESC mDepthStencilDescriptor;
|
||||
};
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
|
||||
BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
|
||||
return new BindGroup(this, builder);
|
||||
return new BindGroup(builder);
|
||||
}
|
||||
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
|
||||
const BindGroupLayoutDescriptor* descriptor) {
|
||||
|
@ -282,10 +282,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
return new ComputePipeline(builder);
|
||||
}
|
||||
DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
|
||||
return new DepthStencilState(this, builder);
|
||||
return new DepthStencilState(builder);
|
||||
}
|
||||
InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
|
||||
return new InputState(this, builder);
|
||||
return new InputState(builder);
|
||||
}
|
||||
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
|
||||
const PipelineLayoutDescriptor* descriptor) {
|
||||
|
@ -296,7 +296,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
|
||||
RenderPassDescriptorBuilder* builder) {
|
||||
return new RenderPassDescriptor(this, builder);
|
||||
return new RenderPassDescriptor(builder);
|
||||
}
|
||||
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
|
||||
return new RenderPipeline(builder);
|
||||
|
@ -305,7 +305,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
return new Sampler(this, descriptor);
|
||||
}
|
||||
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
|
||||
return new ShaderModule(this, builder);
|
||||
return new ShaderModule(builder);
|
||||
}
|
||||
SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
|
||||
return new SwapChain(builder);
|
||||
|
|
|
@ -60,8 +60,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
}
|
||||
|
||||
InputState::InputState(Device* device, InputStateBuilder* builder)
|
||||
: InputStateBase(builder), mDevice(device) {
|
||||
InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) {
|
||||
const auto& attributesSetMask = GetAttributesSetMask();
|
||||
|
||||
unsigned int count = 0;
|
||||
|
|
|
@ -25,12 +25,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class InputState : public InputStateBase {
|
||||
public:
|
||||
InputState(Device* device, InputStateBuilder* builder);
|
||||
InputState(InputStateBuilder* builder);
|
||||
|
||||
const D3D12_INPUT_LAYOUT_DESC& GetD3D12InputLayoutDescriptor() const;
|
||||
|
||||
private:
|
||||
Device* mDevice;
|
||||
D3D12_INPUT_LAYOUT_DESC mInputLayoutDescriptor;
|
||||
D3D12_INPUT_ELEMENT_DESC mInputElementDescriptors[kMaxVertexAttributes];
|
||||
};
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
RenderPassDescriptor::RenderPassDescriptor(Device* device, RenderPassDescriptorBuilder* builder)
|
||||
: RenderPassDescriptorBase(builder), mDevice(device) {
|
||||
RenderPassDescriptor::RenderPassDescriptor(RenderPassDescriptorBuilder* builder)
|
||||
: RenderPassDescriptorBase(builder) {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
// Get and fill an RTV heap with the color attachments
|
||||
uint32_t colorAttachmentCount = static_cast<uint32_t>(GetColorAttachmentMask().count());
|
||||
if (colorAttachmentCount != 0) {
|
||||
|
|
|
@ -36,13 +36,12 @@ namespace dawn_native { namespace d3d12 {
|
|||
D3D12_CPU_DESCRIPTOR_HANDLE dsv = {};
|
||||
};
|
||||
|
||||
RenderPassDescriptor(Device* device, RenderPassDescriptorBuilder* builder);
|
||||
RenderPassDescriptor(RenderPassDescriptorBuilder* builder);
|
||||
OMSetRenderTargetArgs GetSubpassOMSetRenderTargetArgs();
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE GetRTVDescriptor(uint32_t attachmentSlot);
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE GetDSVDescriptor();
|
||||
|
||||
private:
|
||||
Device* mDevice = nullptr;
|
||||
DescriptorHeapHandle mRtvHeap = {};
|
||||
DescriptorHeapHandle mDsvHeap = {};
|
||||
};
|
||||
|
|
|
@ -44,8 +44,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
std::array<T, kNumBindingTypes> mMap{};
|
||||
};
|
||||
|
||||
ShaderModule::ShaderModule(Device* device, ShaderModuleBuilder* builder)
|
||||
: ShaderModuleBase(builder), mDevice(device) {
|
||||
ShaderModule::ShaderModule(ShaderModuleBuilder* builder) : ShaderModuleBase(builder) {
|
||||
spirv_cross::CompilerHLSL compiler(builder->AcquireSpirv());
|
||||
|
||||
spirv_cross::CompilerGLSL::Options options_glsl;
|
||||
|
|
|
@ -23,13 +23,11 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
class ShaderModule : public ShaderModuleBase {
|
||||
public:
|
||||
ShaderModule(Device* device, ShaderModuleBuilder* builder);
|
||||
ShaderModule(ShaderModuleBuilder* builder);
|
||||
|
||||
const std::string& GetHLSLSource() const;
|
||||
|
||||
private:
|
||||
Device* mDevice;
|
||||
|
||||
std::string mHlslSource;
|
||||
};
|
||||
|
||||
|
|
|
@ -192,18 +192,18 @@ namespace {
|
|||
};
|
||||
|
||||
return {
|
||||
alignNonPow2(0, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(512, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(1024, textureSpec.texelSize), rowPitch,
|
||||
BufferSpec{alignNonPow2(0, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(512, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(1024, textureSpec.texelSize), rowPitch},
|
||||
|
||||
alignNonPow2(32, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(64, textureSpec.texelSize), rowPitch,
|
||||
BufferSpec{alignNonPow2(32, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(64, textureSpec.texelSize), rowPitch},
|
||||
|
||||
alignNonPow2(31, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(257, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(511, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(513, textureSpec.texelSize), rowPitch,
|
||||
alignNonPow2(1023, textureSpec.texelSize), rowPitch,
|
||||
BufferSpec{alignNonPow2(31, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(257, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(511, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(513, textureSpec.texelSize), rowPitch},
|
||||
BufferSpec{alignNonPow2(1023, textureSpec.texelSize), rowPitch},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,11 @@ config("spirv_cross_public") {
|
|||
static_library("spirv_cross") {
|
||||
public_configs = [ ":spirv_cross_public" ]
|
||||
|
||||
cflags_cc = [ "-Wno-implicit-fallthrough" ]
|
||||
cflags_cc = [
|
||||
"-Wno-implicit-fallthrough",
|
||||
"-Wno-return-type",
|
||||
"-Wno-sign-compare",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${spirv_cross_dir}/GLSL.std.450.h",
|
||||
|
|
Loading…
Reference in New Issue