Make dawn_native use its own header for Dawn datatypes

The dawn.h and dawncpp.h structure definitions references dawnFoo or
dawn::Foo respectively when it should reference dawn_native::FooBase* in
dawn_native. Autogenerate files to declare the dawn_native version of
the structs and change the ProcTable generation to use it instead.

This is important to make libdawn_native a shared library because
currently it was depending on dawncpp's definition of .Get().
This commit is contained in:
Corentin Wallez 2018-07-25 17:03:23 +02:00 committed by Corentin Wallez
parent 5d313225ff
commit 36afbb6a0d
67 changed files with 231 additions and 141 deletions

View File

@ -479,6 +479,8 @@ def main():
if 'dawn_native_utils' in targets: if 'dawn_native_utils' in targets:
renders.append(FileRender('dawn_native/ValidationUtils.h', 'dawn_native/ValidationUtils_autogen.h', base_backend_params)) renders.append(FileRender('dawn_native/ValidationUtils.h', 'dawn_native/ValidationUtils_autogen.h', base_backend_params))
renders.append(FileRender('dawn_native/ValidationUtils.cpp', 'dawn_native/ValidationUtils_autogen.cpp', base_backend_params)) renders.append(FileRender('dawn_native/ValidationUtils.cpp', 'dawn_native/ValidationUtils_autogen.cpp', base_backend_params))
renders.append(FileRender('dawn_native/api_structs.h', 'dawn_native/dawn_structs_autogen.h', base_backend_params))
renders.append(FileRender('dawn_native/api_structs.cpp', 'dawn_native/dawn_structs_autogen.cpp', base_backend_params))
if 'wire' in targets: if 'wire' in targets:
renders.append(FileRender('wire/WireCmd.h', 'wire/WireCmd_autogen.h', base_backend_params)) renders.append(FileRender('wire/WireCmd.h', 'wire/WireCmd_autogen.h', base_backend_params))

View File

@ -12,11 +12,9 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#include "dawn/dawn.h"
#include "dawn/dawncpp.h"
#include "common/Assert.h" #include "common/Assert.h"
#include "dawn_native/dawn_platform.h"
#include "dawn_native/ErrorData.h" #include "dawn_native/ErrorData.h"
#include "dawn_native/ValidationUtils_autogen.h" #include "dawn_native/ValidationUtils_autogen.h"
#include "dawn_native/{{namespace}}/GeneratedCodeIncludes.h" #include "dawn_native/{{namespace}}/GeneratedCodeIncludes.h"
@ -51,7 +49,7 @@ namespace {{namespace}} {
{%- if arg.type.category in ["enum", "bitmask"] -%} {%- if arg.type.category in ["enum", "bitmask"] -%}
static_cast<dawn::{{as_cppType(arg.type.name)}}>({{as_varName(arg.name)}}) static_cast<dawn::{{as_cppType(arg.type.name)}}>({{as_varName(arg.name)}})
{%- elif arg.type.category == "structure" and arg.annotation != "value" -%} {%- elif arg.type.category == "structure" and arg.annotation != "value" -%}
reinterpret_cast<const dawn::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}}) reinterpret_cast<const {{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}})
{%- else -%} {%- else -%}
{{as_varName(arg.name)}} {{as_varName(arg.name)}}
{%- endif -%} {%- endif -%}
@ -169,7 +167,7 @@ namespace {{namespace}} {
{%- if arg.type.category in ["enum", "bitmask"] -%} {%- if arg.type.category in ["enum", "bitmask"] -%}
static_cast<dawn::{{as_cppType(arg.type.name)}}>({{as_varName(arg.name)}}) static_cast<dawn::{{as_cppType(arg.type.name)}}>({{as_varName(arg.name)}})
{%- elif arg.type.category == "structure" and arg.annotation != "value" -%} {%- elif arg.type.category == "structure" and arg.annotation != "value" -%}
reinterpret_cast<const dawn::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}}) reinterpret_cast<const {{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}})
{%- else -%} {%- else -%}
{{as_varName(arg.name)}} {{as_varName(arg.name)}}
{%- endif -%} {%- endif -%}

View File

@ -0,0 +1,37 @@
//* Copyright 2018 The Dawn Authors
//*
//* Licensed under the Apache License, Version 2.0 (the "License");
//* you may not use this file except in compliance with the License.
//* You may obtain a copy of the License at
//*
//* http://www.apache.org/licenses/LICENSE-2.0
//*
//* Unless required by applicable law or agreed to in writing, software
//* distributed under the License is distributed on an "AS IS" BASIS,
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//* See the License for the specific language governing permissions and
//* limitations under the License.
#include "dawn_native/dawn_structs_autogen.h"
namespace dawn_native {
{% for type in by_category["structure"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) %}
static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
{% if type.extensible %}
static_assert(offsetof({{CppType}}, nextInChain) == offsetof({{CType}}, nextInChain),
"offsetof mismatch for {{CppType}}::nextInChain");
{% endif %}
{% for member in type.members %}
{% set memberName = member.name.camelCase() %}
static_assert(offsetof({{CppType}}, {{memberName}}) == offsetof({{CType}}, {{memberName}}),
"offsetof mismatch for {{CppType}}::{{memberName}}");
{% endfor %}
{% endfor %}
}

View File

@ -0,0 +1,45 @@
//* Copyright 2017 The Dawn Authors
//*
//* Licensed under the Apache License, Version 2.0 (the "License");
//* you may not use this file except in compliance with the License.
//* You may obtain a copy of the License at
//*
//* http://www.apache.org/licenses/LICENSE-2.0
//*
//* Unless required by applicable law or agreed to in writing, software
//* distributed under the License is distributed on an "AS IS" BASIS,
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//* See the License for the specific language governing permissions and
//* limitations under the License.
#ifndef DAWNNATIVE_DAWN_STRUCTS_H_
#define DAWNNATIVE_DAWN_STRUCTS_H_
#include "dawn/dawncpp.h"
#include "dawn_native/Forward.h"
namespace dawn_native {
{% for type in by_category["structure"] %}
struct {{as_cppType(type.name)}} {
{% if type.extensible %}
const void* nextInChain = nullptr;
{% endif %}
{% for member in type.members %}
{% if member.type.category == "object" %}
{{decorate(as_varName(member.name), as_cppType(member.type.name) + "Base*", member)}};
{% elif member.type.category == "structure" %}
{{as_annotated_cppType(member)}};
{% elif member.type.category in ["enum", "bitmask"] %}
{{decorate(as_varName(member.name), "dawn::" + as_cppType(member.type.name), member)}};
{% else %}
{{as_annotated_cppType(member)}};
{% endif %}
{% endfor %}
};
{% endfor %}
} // namespace dawn_native
#endif // DAWNNATIVE_DAWN_STRUCTS_H_

View File

@ -21,7 +21,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -23,9 +23,8 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidateBindGroupLayoutDescriptor( MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
DeviceBase*, const BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr"); DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
std::bitset<kMaxBindingsPerGroup> bindingsSet; std::bitset<kMaxBindingsPerGroup> bindingsSet;
@ -74,7 +73,7 @@ namespace dawn_native {
// BindGroupLayoutBase // BindGroupLayoutBase
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device, BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
const dawn::BindGroupLayoutDescriptor* descriptor, const BindGroupLayoutDescriptor* descriptor,
bool blueprint) bool blueprint)
: mDevice(device), mIsBlueprint(blueprint) { : mDevice(device), mIsBlueprint(blueprint) {
for (uint32_t i = 0; i < descriptor->numBindings; ++i) { for (uint32_t i = 0; i < descriptor->numBindings; ++i) {

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>
@ -28,12 +28,12 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*, MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
const dawn::BindGroupLayoutDescriptor* descriptor); const BindGroupLayoutDescriptor* descriptor);
class BindGroupLayoutBase : public RefCounted { class BindGroupLayoutBase : public RefCounted {
public: public:
BindGroupLayoutBase(DeviceBase* device, BindGroupLayoutBase(DeviceBase* device,
const dawn::BindGroupLayoutDescriptor* descriptor, const BindGroupLayoutDescriptor* descriptor,
bool blueprint = false); bool blueprint = false);
~BindGroupLayoutBase() override; ~BindGroupLayoutBase() override;

View File

@ -19,7 +19,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -18,7 +18,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <string> #include <string>

View File

@ -28,7 +28,6 @@ Generate(
${GENERATOR_COMMON_ARGS} ${GENERATOR_COMMON_ARGS}
-T dawn_native_utils -T dawn_native_utils
) )
target_link_libraries(dawn_native_utils_autogen)
function(GenerateProcTable backend) function(GenerateProcTable backend)
Generate( Generate(
@ -327,6 +326,7 @@ endif()
################################################################################ ################################################################################
list(APPEND DAWN_NATIVE_SOURCES list(APPEND DAWN_NATIVE_SOURCES
${DAWN_NATIVE_DIR}/dawn_platform.h
${DAWN_NATIVE_DIR}/BindGroup.cpp ${DAWN_NATIVE_DIR}/BindGroup.cpp
${DAWN_NATIVE_DIR}/BindGroup.h ${DAWN_NATIVE_DIR}/BindGroup.h
${DAWN_NATIVE_DIR}/BindGroupLayout.cpp ${DAWN_NATIVE_DIR}/BindGroupLayout.cpp
@ -337,18 +337,18 @@ list(APPEND DAWN_NATIVE_SOURCES
${DAWN_NATIVE_DIR}/Builder.h ${DAWN_NATIVE_DIR}/Builder.h
${DAWN_NATIVE_DIR}/Buffer.cpp ${DAWN_NATIVE_DIR}/Buffer.cpp
${DAWN_NATIVE_DIR}/Buffer.h ${DAWN_NATIVE_DIR}/Buffer.h
${DAWN_NATIVE_DIR}/Commands.cpp
${DAWN_NATIVE_DIR}/Commands.h
${DAWN_NATIVE_DIR}/CommandAllocator.cpp ${DAWN_NATIVE_DIR}/CommandAllocator.cpp
${DAWN_NATIVE_DIR}/CommandAllocator.h ${DAWN_NATIVE_DIR}/CommandAllocator.h
${DAWN_NATIVE_DIR}/CommandBuffer.cpp ${DAWN_NATIVE_DIR}/CommandBuffer.cpp
${DAWN_NATIVE_DIR}/CommandBuffer.h ${DAWN_NATIVE_DIR}/CommandBuffer.h
${DAWN_NATIVE_DIR}/Commands.cpp
${DAWN_NATIVE_DIR}/Commands.h
${DAWN_NATIVE_DIR}/ComputePipeline.cpp ${DAWN_NATIVE_DIR}/ComputePipeline.cpp
${DAWN_NATIVE_DIR}/ComputePipeline.h ${DAWN_NATIVE_DIR}/ComputePipeline.h
${DAWN_NATIVE_DIR}/DepthStencilState.cpp
${DAWN_NATIVE_DIR}/DepthStencilState.h
${DAWN_NATIVE_DIR}/CommandBufferStateTracker.cpp ${DAWN_NATIVE_DIR}/CommandBufferStateTracker.cpp
${DAWN_NATIVE_DIR}/CommandBufferStateTracker.h ${DAWN_NATIVE_DIR}/CommandBufferStateTracker.h
${DAWN_NATIVE_DIR}/DepthStencilState.cpp
${DAWN_NATIVE_DIR}/DepthStencilState.h
${DAWN_NATIVE_DIR}/Device.cpp ${DAWN_NATIVE_DIR}/Device.cpp
${DAWN_NATIVE_DIR}/Device.h ${DAWN_NATIVE_DIR}/Device.h
${DAWN_NATIVE_DIR}/Error.cpp ${DAWN_NATIVE_DIR}/Error.cpp

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_COMMANDBUFFER_H_ #ifndef DAWNNATIVE_COMMANDBUFFER_H_
#define DAWNNATIVE_COMMANDBUFFER_H_ #define DAWNNATIVE_COMMANDBUFFER_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "dawn_native/Builder.h" #include "dawn_native/Builder.h"
#include "dawn_native/CommandAllocator.h" #include "dawn_native/CommandAllocator.h"

View File

@ -18,7 +18,7 @@
#include "dawn_native/RenderPassDescriptor.h" #include "dawn_native/RenderPassDescriptor.h"
#include "dawn_native/Texture.h" #include "dawn_native/Texture.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -19,7 +19,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -74,7 +74,7 @@ namespace dawn_native {
} }
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout( ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
BindGroupLayoutBase blueprint(this, descriptor, true); BindGroupLayoutBase blueprint(this, descriptor, true);
auto iter = mCaches->bindGroupLayouts.find(&blueprint); auto iter = mCaches->bindGroupLayouts.find(&blueprint);
@ -99,7 +99,7 @@ namespace dawn_native {
return new BindGroupBuilder(this); return new BindGroupBuilder(this);
} }
BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout( BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
BindGroupLayoutBase* result = nullptr; BindGroupLayoutBase* result = nullptr;
if (ConsumedError(CreateBindGroupLayoutInternal(&result, descriptor))) { if (ConsumedError(CreateBindGroupLayoutInternal(&result, descriptor))) {
@ -127,7 +127,7 @@ namespace dawn_native {
return new InputStateBuilder(this); return new InputStateBuilder(this);
} }
PipelineLayoutBase* DeviceBase::CreatePipelineLayout( PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
PipelineLayoutBase* result = nullptr; PipelineLayoutBase* result = nullptr;
if (ConsumedError(CreatePipelineLayoutInternal(&result, descriptor))) { if (ConsumedError(CreatePipelineLayoutInternal(&result, descriptor))) {
@ -151,7 +151,7 @@ namespace dawn_native {
RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() { RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() {
return new RenderPipelineBuilder(this); return new RenderPipelineBuilder(this);
} }
SamplerBase* DeviceBase::CreateSampler(const dawn::SamplerDescriptor* descriptor) { SamplerBase* DeviceBase::CreateSampler(const SamplerDescriptor* descriptor) {
SamplerBase* result = nullptr; SamplerBase* result = nullptr;
if (ConsumedError(CreateSamplerInternal(&result, descriptor))) { if (ConsumedError(CreateSamplerInternal(&result, descriptor))) {
@ -193,7 +193,7 @@ namespace dawn_native {
MaybeError DeviceBase::CreateBindGroupLayoutInternal( MaybeError DeviceBase::CreateBindGroupLayoutInternal(
BindGroupLayoutBase** result, BindGroupLayoutBase** result,
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor)); DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor)); DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
return {}; return {};
@ -201,7 +201,7 @@ namespace dawn_native {
MaybeError DeviceBase::CreatePipelineLayoutInternal( MaybeError DeviceBase::CreatePipelineLayoutInternal(
PipelineLayoutBase** result, PipelineLayoutBase** result,
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
DAWN_TRY(ValidatePipelineLayoutDescriptor(this, descriptor)); DAWN_TRY(ValidatePipelineLayoutDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor)); DAWN_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor));
return {}; return {};
@ -213,7 +213,7 @@ namespace dawn_native {
} }
MaybeError DeviceBase::CreateSamplerInternal(SamplerBase** result, MaybeError DeviceBase::CreateSamplerInternal(SamplerBase** result,
const dawn::SamplerDescriptor* descriptor) { const SamplerDescriptor* descriptor) {
DAWN_TRY(ValidateSamplerDescriptor(this, descriptor)); DAWN_TRY(ValidateSamplerDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor)); DAWN_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor));
return {}; return {};

View File

@ -19,7 +19,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {
@ -77,24 +77,23 @@ namespace dawn_native {
// instead of a backend Foo object. If the blueprint doesn't match an object in the // instead of a backend Foo object. If the blueprint doesn't match an object in the
// cache, then the builder is used to make a new object. // cache, then the builder is used to make a new object.
ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout( ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout(
const dawn::BindGroupLayoutDescriptor* descriptor); const BindGroupLayoutDescriptor* descriptor);
void UncacheBindGroupLayout(BindGroupLayoutBase* obj); void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
// Dawn API // Dawn API
BindGroupBuilder* CreateBindGroupBuilder(); BindGroupBuilder* CreateBindGroupBuilder();
BindGroupLayoutBase* CreateBindGroupLayout( BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
const dawn::BindGroupLayoutDescriptor* descriptor);
BlendStateBuilder* CreateBlendStateBuilder(); BlendStateBuilder* CreateBlendStateBuilder();
BufferBuilder* CreateBufferBuilder(); BufferBuilder* CreateBufferBuilder();
CommandBufferBuilder* CreateCommandBufferBuilder(); CommandBufferBuilder* CreateCommandBufferBuilder();
ComputePipelineBuilder* CreateComputePipelineBuilder(); ComputePipelineBuilder* CreateComputePipelineBuilder();
DepthStencilStateBuilder* CreateDepthStencilStateBuilder(); DepthStencilStateBuilder* CreateDepthStencilStateBuilder();
InputStateBuilder* CreateInputStateBuilder(); InputStateBuilder* CreateInputStateBuilder();
PipelineLayoutBase* CreatePipelineLayout(const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
QueueBase* CreateQueue(); QueueBase* CreateQueue();
RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder(); RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder();
RenderPipelineBuilder* CreateRenderPipelineBuilder(); RenderPipelineBuilder* CreateRenderPipelineBuilder();
SamplerBase* CreateSampler(const dawn::SamplerDescriptor* descriptor); SamplerBase* CreateSampler(const SamplerDescriptor* descriptor);
ShaderModuleBuilder* CreateShaderModuleBuilder(); ShaderModuleBuilder* CreateShaderModuleBuilder();
SwapChainBuilder* CreateSwapChainBuilder(); SwapChainBuilder* CreateSwapChainBuilder();
TextureBuilder* CreateTextureBuilder(); TextureBuilder* CreateTextureBuilder();
@ -106,20 +105,19 @@ namespace dawn_native {
private: private:
virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) = 0; const BindGroupLayoutDescriptor* descriptor) = 0;
virtual ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( virtual ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) = 0; const PipelineLayoutDescriptor* descriptor) = 0;
virtual ResultOrError<QueueBase*> CreateQueueImpl() = 0; virtual ResultOrError<QueueBase*> CreateQueueImpl() = 0;
virtual ResultOrError<SamplerBase*> CreateSamplerImpl( virtual ResultOrError<SamplerBase*> CreateSamplerImpl(
const dawn::SamplerDescriptor* descriptor) = 0; const SamplerDescriptor* descriptor) = 0;
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result, MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
const dawn::BindGroupLayoutDescriptor* descriptor); const BindGroupLayoutDescriptor* descriptor);
MaybeError CreatePipelineLayoutInternal(PipelineLayoutBase** result, MaybeError CreatePipelineLayoutInternal(PipelineLayoutBase** result,
const dawn::PipelineLayoutDescriptor* descriptor); const PipelineLayoutDescriptor* descriptor);
MaybeError CreateQueueInternal(QueueBase** result); MaybeError CreateQueueInternal(QueueBase** result);
MaybeError CreateSamplerInternal(SamplerBase** result, MaybeError CreateSamplerInternal(SamplerBase** result, const SamplerDescriptor* descriptor);
const dawn::SamplerDescriptor* descriptor);
void ConsumeError(ErrorData* error); void ConsumeError(ErrorData* error);

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_PASSRESOURCEUSAGE_H #ifndef DAWNNATIVE_PASSRESOURCEUSAGE_H
#define DAWNNATIVE_PASSRESOURCEUSAGE_H #define DAWNNATIVE_PASSRESOURCEUSAGE_H
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <vector> #include <vector>

View File

@ -19,7 +19,7 @@
#include "common/BitSetIterator.h" #include "common/BitSetIterator.h"
#include "common/Constants.h" #include "common/Constants.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>

View File

@ -27,7 +27,7 @@ namespace dawn_native {
PipelineBase::PipelineBase(PipelineBuilder* builder) PipelineBase::PipelineBase(PipelineBuilder* builder)
: mStageMask(builder->mStageMask), mLayout(std::move(builder->mLayout)) { : mStageMask(builder->mStageMask), mLayout(std::move(builder->mLayout)) {
if (!mLayout) { if (!mLayout) {
dawn::PipelineLayoutDescriptor descriptor; PipelineLayoutDescriptor descriptor;
descriptor.numBindGroupLayouts = 0; descriptor.numBindGroupLayouts = 0;
descriptor.bindGroupLayouts = nullptr; descriptor.bindGroupLayouts = nullptr;
mLayout = builder->GetParentBuilder()->GetDevice()->CreatePipelineLayout(&descriptor); mLayout = builder->GetParentBuilder()->GetDevice()->CreatePipelineLayout(&descriptor);

View File

@ -22,7 +22,7 @@
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn_native/ShaderModule.h" #include "dawn_native/ShaderModule.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -21,12 +21,12 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*, MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr"); DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
DAWN_TRY_ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups, DAWN_TRY_ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups,
"too many bind group layouts"); "too many bind group layouts");
for (uint32_t i = 0; i < descriptor->numBindGroupLayouts; ++i) { for (uint32_t i = 0; i < descriptor->numBindGroupLayouts; ++i) {
DAWN_TRY_ASSERT(descriptor->bindGroupLayouts[i].Get() != nullptr, DAWN_TRY_ASSERT(descriptor->bindGroupLayouts[i] != nullptr,
"bind group layouts may not be null"); "bind group layouts may not be null");
} }
return {}; return {};
@ -35,12 +35,11 @@ namespace dawn_native {
// PipelineLayoutBase // PipelineLayoutBase
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device, PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
const dawn::PipelineLayoutDescriptor* descriptor) const PipelineLayoutDescriptor* descriptor)
: mDevice(device) { : mDevice(device) {
ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups); ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups);
for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) { for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) {
mBindGroupLayouts[group] = mBindGroupLayouts[group] = descriptor->bindGroupLayouts[group];
reinterpret_cast<BindGroupLayoutBase*>(descriptor->bindGroupLayouts[group].Get());
mMask.set(group); mMask.set(group);
} }
} }

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>
@ -28,13 +28,13 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*, MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
const dawn::PipelineLayoutDescriptor* descriptor); const PipelineLayoutDescriptor* descriptor);
using BindGroupLayoutArray = std::array<Ref<BindGroupLayoutBase>, kMaxBindGroups>; using BindGroupLayoutArray = std::array<Ref<BindGroupLayoutBase>, kMaxBindGroups>;
class PipelineLayoutBase : public RefCounted { class PipelineLayoutBase : public RefCounted {
public: public:
PipelineLayoutBase(DeviceBase* device, const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayoutBase(DeviceBase* device, const PipelineLayoutDescriptor* descriptor);
const BindGroupLayoutBase* GetBindGroupLayout(size_t group) const; const BindGroupLayoutBase* GetBindGroupLayout(size_t group) const;
const std::bitset<kMaxBindGroups> GetBindGroupLayoutsMask() const; const std::bitset<kMaxBindGroups> GetBindGroupLayoutsMask() const;

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -20,7 +20,7 @@
#include "dawn_native/InputState.h" #include "dawn_native/InputState.h"
#include "dawn_native/Pipeline.h" #include "dawn_native/Pipeline.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -19,7 +19,7 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidateSamplerDescriptor(DeviceBase*, const dawn::SamplerDescriptor* descriptor) { MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descriptor) {
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr"); DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
DAWN_TRY(ValidateFilterMode(descriptor->minFilter)); DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
DAWN_TRY(ValidateFilterMode(descriptor->magFilter)); DAWN_TRY(ValidateFilterMode(descriptor->magFilter));
@ -32,7 +32,7 @@ namespace dawn_native {
// SamplerBase // SamplerBase
SamplerBase::SamplerBase(DeviceBase*, const dawn::SamplerDescriptor*) { SamplerBase::SamplerBase(DeviceBase*, const SamplerDescriptor*) {
} }
} // namespace dawn_native } // namespace dawn_native

View File

@ -18,18 +18,17 @@
#include "dawn_native/Error.h" #include "dawn_native/Error.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {
class DeviceBase; class DeviceBase;
MaybeError ValidateSamplerDescriptor(DeviceBase* device, MaybeError ValidateSamplerDescriptor(DeviceBase* device, const SamplerDescriptor* descriptor);
const dawn::SamplerDescriptor* descriptor);
class SamplerBase : public RefCounted { class SamplerBase : public RefCounted {
public: public:
SamplerBase(DeviceBase* device, const dawn::SamplerDescriptor* descriptor); SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor);
}; };
} // namespace dawn_native } // namespace dawn_native

View File

@ -20,7 +20,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -20,7 +20,7 @@
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawn_wsi.h" #include "dawn/dawn_wsi.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -19,7 +19,7 @@
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
#include "dawn_native/RefCounted.h" #include "dawn_native/RefCounted.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace dawn_native {

View File

@ -19,8 +19,7 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayout::BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor)
const dawn::BindGroupLayoutDescriptor* descriptor)
: BindGroupLayoutBase(device, descriptor), mDescriptorCounts{} { : BindGroupLayoutBase(device, descriptor), mDescriptorCounts{} {
const auto& groupInfo = GetBindingInfo(); const auto& groupInfo = GetBindingInfo();

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace d3d12 {
class BindGroupLayout : public BindGroupLayoutBase { class BindGroupLayout : public BindGroupLayoutBase {
public: public:
BindGroupLayout(Device* device, const dawn::BindGroupLayoutDescriptor* descriptor); BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor);
enum DescriptorType { enum DescriptorType {
CBV, CBV,

View File

@ -267,7 +267,7 @@ namespace dawn_native { namespace d3d12 {
return new BindGroup(this, builder); return new BindGroup(this, builder);
} }
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor); return new BindGroupLayout(this, descriptor);
} }
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -292,7 +292,7 @@ namespace dawn_native { namespace d3d12 {
return new InputState(this, builder); return new InputState(this, builder);
} }
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor); return new PipelineLayout(this, descriptor);
} }
ResultOrError<QueueBase*> Device::CreateQueueImpl() { ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -305,8 +305,7 @@ namespace dawn_native { namespace d3d12 {
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
return new RenderPipeline(builder); return new RenderPipeline(builder);
} }
ResultOrError<SamplerBase*> Device::CreateSamplerImpl( ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor); return new Sampler(this, descriptor);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_D3D12_DEVICED3D12_H_ #ifndef DAWNNATIVE_D3D12_DEVICED3D12_H_
#define DAWNNATIVE_D3D12_DEVICED3D12_H_ #define DAWNNATIVE_D3D12_DEVICED3D12_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "common/SerialQueue.h" #include "common/SerialQueue.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
@ -78,12 +78,11 @@ namespace dawn_native { namespace d3d12 {
private: private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) override; const BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) override; const PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override; ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl( ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
uint64_t mSerial = 0; uint64_t mSerial = 0;
ComPtr<ID3D12Fence> mFence; ComPtr<ID3D12Fence> mFence;

View File

@ -18,7 +18,7 @@
#include "dawn_native/d3d12/d3d12_platform.h" #include "dawn_native/d3d12/d3d12_platform.h"
#include "dawn/dawn_wsi.h" #include "dawn/dawn_wsi.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <vector> #include <vector>

View File

@ -23,7 +23,7 @@ using Microsoft::WRL::ComPtr;
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor) PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) { : PipelineLayoutBase(device, descriptor) {
D3D12_ROOT_PARAMETER rootParameters[kMaxBindGroups * 2]; D3D12_ROOT_PARAMETER rootParameters[kMaxBindGroups * 2];

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace d3d12 {
class PipelineLayout : public PipelineLayoutBase { class PipelineLayout : public PipelineLayoutBase {
public: public:
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
uint32_t GetCbvUavSrvRootParameterIndex(uint32_t group) const; uint32_t GetCbvUavSrvRootParameterIndex(uint32_t group) const;
uint32_t GetSamplerRootParameterIndex(uint32_t group) const; uint32_t GetSamplerRootParameterIndex(uint32_t group) const;

View File

@ -33,7 +33,7 @@ namespace dawn_native { namespace d3d12 {
} }
} // namespace } // namespace
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor) Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) { : SamplerBase(device, descriptor) {
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx
// hex value, decimal value, min linear, mag linear, mip linear // hex value, decimal value, min linear, mag linear, mip linear

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace d3d12 {
class Sampler : public SamplerBase { class Sampler : public SamplerBase {
public: public:
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor); Sampler(Device* device, const SamplerDescriptor* descriptor);
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const; const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_ #ifndef DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
#define DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_ #define DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>

View File

@ -0,0 +1,25 @@
// Copyright 2018 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DAWNNATIVE_DAWNPLATFORM_H_
#define DAWNNATIVE_DAWNPLATFORM_H_
// Use dawncpp to have the enum and bitfield definitions
#include <dawn/dawncpp.h>
// Use our autogenerated version of the dawn structures that point to dawn_native object types
// (dawn::Buffer is dawn_native::BufferBase*)
#include <dawn_native/dawn_structs_autogen.h>
#endif // DAWNNATIVE_DAWNPLATFORM_H_

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_METAL_DEVICEMTL_H_ #ifndef DAWNNATIVE_METAL_DEVICEMTL_H_
#define DAWNNATIVE_METAL_DEVICEMTL_H_ #define DAWNNATIVE_METAL_DEVICEMTL_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "common/Serial.h" #include "common/Serial.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
@ -64,12 +64,11 @@ namespace dawn_native { namespace metal {
private: private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) override; const BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) override; const PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override; ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl( ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
void OnCompletedHandler(); void OnCompletedHandler();

View File

@ -86,7 +86,7 @@ namespace dawn_native { namespace metal {
return new BindGroup(builder); return new BindGroup(builder);
} }
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor); return new BindGroupLayout(this, descriptor);
} }
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -111,7 +111,7 @@ namespace dawn_native { namespace metal {
return new InputState(builder); return new InputState(builder);
} }
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor); return new PipelineLayout(this, descriptor);
} }
RenderPassDescriptorBase* Device::CreateRenderPassDescriptor( RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
@ -124,8 +124,7 @@ namespace dawn_native { namespace metal {
ResultOrError<QueueBase*> Device::CreateQueueImpl() { ResultOrError<QueueBase*> Device::CreateQueueImpl() {
return new Queue(this); return new Queue(this);
} }
ResultOrError<SamplerBase*> Device::CreateSamplerImpl( ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor); return new Sampler(this, descriptor);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -31,7 +31,7 @@ namespace dawn_native { namespace metal {
class PipelineLayout : public PipelineLayoutBase { class PipelineLayout : public PipelineLayoutBase {
public: public:
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
using BindingIndexInfo = using BindingIndexInfo =
std::array<std::array<uint32_t, kMaxBindingsPerGroup>, kMaxBindGroups>; std::array<std::array<uint32_t, kMaxBindingsPerGroup>, kMaxBindGroups>;

View File

@ -20,7 +20,7 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor) PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) { : PipelineLayoutBase(device, descriptor) {
// Each stage has its own numbering namespace in CompilerMSL. // Each stage has its own numbering namespace in CompilerMSL.
for (auto stage : IterateStages(kAllStages)) { for (auto stage : IterateStages(kAllStages)) {

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace metal {
class Sampler : public SamplerBase { class Sampler : public SamplerBase {
public: public:
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor); Sampler(Device* device, const SamplerDescriptor* descriptor);
~Sampler(); ~Sampler();
id<MTLSamplerState> GetMTLSamplerState(); id<MTLSamplerState> GetMTLSamplerState();

View File

@ -49,7 +49,7 @@ namespace dawn_native { namespace metal {
} }
} }
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor) Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) { : SamplerBase(device, descriptor) {
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new]; MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
[mtlDesc autorelease]; [mtlDesc autorelease];

View File

@ -40,7 +40,7 @@ namespace dawn_native { namespace null {
return new BindGroup(builder); return new BindGroup(builder);
} }
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor); return new BindGroupLayout(this, descriptor);
} }
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -65,7 +65,7 @@ namespace dawn_native { namespace null {
return new InputState(builder); return new InputState(builder);
} }
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor); return new PipelineLayout(this, descriptor);
} }
ResultOrError<QueueBase*> Device::CreateQueueImpl() { ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -78,8 +78,7 @@ namespace dawn_native { namespace null {
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
return new RenderPipeline(builder); return new RenderPipeline(builder);
} }
ResultOrError<SamplerBase*> Device::CreateSamplerImpl( ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor); return new Sampler(this, descriptor);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_NULL_NULLBACKEND_H_ #ifndef DAWNNATIVE_NULL_NULLBACKEND_H_
#define DAWNNATIVE_NULL_NULLBACKEND_H_ #define DAWNNATIVE_NULL_NULLBACKEND_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "dawn_native/BindGroup.h" #include "dawn_native/BindGroup.h"
#include "dawn_native/BindGroupLayout.h" #include "dawn_native/BindGroupLayout.h"
@ -118,12 +118,11 @@ namespace dawn_native { namespace null {
private: private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) override; const BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) override; const PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override; ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl( ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations; std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
}; };

View File

@ -54,7 +54,7 @@ namespace dawn_native { namespace opengl {
return new BindGroup(builder); return new BindGroup(builder);
} }
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor); return new BindGroupLayout(this, descriptor);
} }
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -79,7 +79,7 @@ namespace dawn_native { namespace opengl {
return new InputState(builder); return new InputState(builder);
} }
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor); return new PipelineLayout(this, descriptor);
} }
ResultOrError<QueueBase*> Device::CreateQueueImpl() { ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -92,8 +92,7 @@ namespace dawn_native { namespace opengl {
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
return new RenderPipeline(builder); return new RenderPipeline(builder);
} }
ResultOrError<SamplerBase*> Device::CreateSamplerImpl( ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor); return new Sampler(this, descriptor);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_OPENGL_DEVICEGL_H_ #ifndef DAWNNATIVE_OPENGL_DEVICEGL_H_
#define DAWNNATIVE_OPENGL_DEVICEGL_H_ #define DAWNNATIVE_OPENGL_DEVICEGL_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "common/Platform.h" #include "common/Platform.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
@ -52,12 +52,11 @@ namespace dawn_native { namespace opengl {
private: private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) override; const BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) override; const PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override; ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl( ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
}; };
}} // namespace dawn_native::opengl }} // namespace dawn_native::opengl

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_ #ifndef DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
#define DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_ #define DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "glad/glad.h" #include "glad/glad.h"

View File

@ -20,7 +20,7 @@
namespace dawn_native { namespace opengl { namespace dawn_native { namespace opengl {
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor) PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) { : PipelineLayoutBase(device, descriptor) {
GLuint uboIndex = 0; GLuint uboIndex = 0;
GLuint samplerIndex = 0; GLuint samplerIndex = 0;

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace opengl {
class PipelineLayout : public PipelineLayoutBase { class PipelineLayout : public PipelineLayoutBase {
public: public:
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
using BindingIndexInfo = using BindingIndexInfo =
std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>; std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>;

View File

@ -71,7 +71,7 @@ namespace dawn_native { namespace opengl {
} // namespace } // namespace
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor) Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) { : SamplerBase(device, descriptor) {
glGenSamplers(1, &mHandle); glGenSamplers(1, &mHandle);
glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(descriptor->magFilter)); glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(descriptor->magFilter));

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace opengl {
class Sampler : public SamplerBase { class Sampler : public SamplerBase {
public: public:
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor); Sampler(Device* device, const SamplerDescriptor* descriptor);
GLuint GetHandle() const; GLuint GetHandle() const;

View File

@ -54,8 +54,7 @@ namespace dawn_native { namespace vulkan {
} }
} }
BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayout::BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor)
const dawn::BindGroupLayoutDescriptor* descriptor)
: BindGroupLayoutBase(device, descriptor) { : BindGroupLayoutBase(device, descriptor) {
const auto& info = GetBindingInfo(); const auto& info = GetBindingInfo();

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace vulkan {
class BindGroupLayout : public BindGroupLayoutBase { class BindGroupLayout : public BindGroupLayoutBase {
public: public:
BindGroupLayout(Device* device, const dawn::BindGroupLayoutDescriptor* descriptor); BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor);
~BindGroupLayout(); ~BindGroupLayout();
VkDescriptorSetLayout GetHandle() const; VkDescriptorSetLayout GetHandle() const;

View File

@ -225,7 +225,7 @@ namespace dawn_native { namespace vulkan {
return new BindGroup(builder); return new BindGroup(builder);
} }
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) { const BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor); return new BindGroupLayout(this, descriptor);
} }
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) { BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -250,7 +250,7 @@ namespace dawn_native { namespace vulkan {
return new InputState(builder); return new InputState(builder);
} }
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) { const PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor); return new PipelineLayout(this, descriptor);
} }
ResultOrError<QueueBase*> Device::CreateQueueImpl() { ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -263,8 +263,7 @@ namespace dawn_native { namespace vulkan {
RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) { RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
return new RenderPipeline(builder); return new RenderPipeline(builder);
} }
ResultOrError<SamplerBase*> Device::CreateSamplerImpl( ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor); return new Sampler(this, descriptor);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -15,7 +15,7 @@
#ifndef DAWNNATIVE_VULKAN_DEVICEVK_H_ #ifndef DAWNNATIVE_VULKAN_DEVICEVK_H_
#define DAWNNATIVE_VULKAN_DEVICEVK_H_ #define DAWNNATIVE_VULKAN_DEVICEVK_H_
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include "common/DynamicLib.h" #include "common/DynamicLib.h"
#include "common/Serial.h" #include "common/Serial.h"
@ -83,12 +83,11 @@ namespace dawn_native { namespace vulkan {
private: private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl( ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const dawn::BindGroupLayoutDescriptor* descriptor) override; const BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl( ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const dawn::PipelineLayoutDescriptor* descriptor) override; const PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override; ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl( ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
bool CreateInstance(VulkanGlobalKnobs* usedKnobs, bool CreateInstance(VulkanGlobalKnobs* usedKnobs,
const std::vector<const char*>& requiredExtensions); const std::vector<const char*>& requiredExtensions);

View File

@ -18,7 +18,7 @@
#include "dawn_native/vulkan/VulkanInfo.h" #include "dawn_native/vulkan/VulkanInfo.h"
#include "dawn/dawn_wsi.h" #include "dawn/dawn_wsi.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
namespace dawn_native { namespace vulkan { namespace dawn_native { namespace vulkan {

View File

@ -22,7 +22,7 @@
namespace dawn_native { namespace vulkan { namespace dawn_native { namespace vulkan {
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor) PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) { : PipelineLayoutBase(device, descriptor) {
// Compute the array of VkDescriptorSetLayouts that will be chained in the create info. // Compute the array of VkDescriptorSetLayouts that will be chained in the create info.
// TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose // TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace vulkan {
class PipelineLayout : public PipelineLayoutBase { class PipelineLayout : public PipelineLayoutBase {
public: public:
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor); PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
~PipelineLayout(); ~PipelineLayout();
VkPipelineLayout GetHandle() const; VkPipelineLayout GetHandle() const;

View File

@ -18,7 +18,7 @@
#include "common/vulkan_platform.h" #include "common/vulkan_platform.h"
#include "common/Constants.h" #include "common/Constants.h"
#include "dawn/dawncpp.h" #include "dawn_native/dawn_platform.h"
#include <array> #include <array>
#include <bitset> #include <bitset>

View File

@ -56,7 +56,7 @@ namespace dawn_native { namespace vulkan {
} }
} // anonymous namespace } // anonymous namespace
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor) Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor), mDevice(device) { : SamplerBase(device, descriptor), mDevice(device) {
VkSamplerCreateInfo createInfo; VkSamplerCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;

View File

@ -24,7 +24,7 @@ namespace dawn_native { namespace vulkan {
class Sampler : public SamplerBase { class Sampler : public SamplerBase {
public: public:
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor); Sampler(Device* device, const SamplerDescriptor* descriptor);
~Sampler(); ~Sampler();
VkSampler GetHandle() const; VkSampler GetHandle() const;