Rename the nxt namespace to dawn

This commit is contained in:
Corentin Wallez 2018-07-18 14:44:20 +02:00 committed by Corentin Wallez
parent 05c90ee4cb
commit ae79c03d45
21 changed files with 102 additions and 105 deletions

View File

@ -53,8 +53,8 @@ In addition to the improved type-safety and subjective prettiness compared to gi
Heres an example of buffer creation: Heres an example of buffer creation:
```cpp ```cpp
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetUsage(nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Mapped) .SetUsage(dawn::BufferUsageBit::Uniform | dawn::BufferUsageBit::Mapped)
.SetSize(42) .SetSize(42)
.GetResult(); .GetResult();
``` ```

View File

@ -14,7 +14,7 @@
#include "dawncpp.h" #include "dawncpp.h"
namespace nxt { namespace dawn {
{% for type in by_category["enum"] + by_category["bitmask"] %} {% for type in by_category["enum"] + by_category["bitmask"] %}
{% set CppType = as_cppType(type.name) %} {% set CppType = as_cppType(type.name) %}

View File

@ -19,10 +19,7 @@
#include "dawn/EnumClassBitmasks.h" #include "dawn/EnumClassBitmasks.h"
// Temporary define to rename NXT to Dawn namespace dawn {
#define dawn nxt
namespace nxt {
{% for type in by_category["enum"] %} {% for type in by_category["enum"] %}
enum class {{as_cppType(type.name)}} : uint32_t { enum class {{as_cppType(type.name)}} : uint32_t {
@ -161,6 +158,6 @@ namespace nxt {
{% endfor %} {% endfor %}
} // namespace nxt } // namespace dawn
#endif // NXTCPP_H #endif // NXTCPP_H

View File

@ -19,7 +19,7 @@
#include <type_traits> #include <type_traits>
namespace nxt { namespace dawn {
template<typename Builder> template<typename Builder>
using BuiltObject = decltype(std::declval<Builder>().GetResult()); using BuiltObject = decltype(std::declval<Builder>().GetResult());

View File

@ -49,9 +49,9 @@ namespace {{namespace}} {
{%- for arg in method.arguments -%} {%- for arg in method.arguments -%}
{%- if not loop.first %}, {% endif -%} {%- if not loop.first %}, {% endif -%}
{%- if arg.type.category in ["enum", "bitmask"] -%} {%- if arg.type.category in ["enum", "bitmask"] -%}
static_cast<nxt::{{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 nxt::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}}) reinterpret_cast<const dawn::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}})
{%- else -%} {%- else -%}
{{as_varName(arg.name)}} {{as_varName(arg.name)}}
{%- endif -%} {%- endif -%}
@ -85,7 +85,7 @@ namespace {{namespace}} {
{% set cppType = as_cppType(arg.type.name) %} {% set cppType = as_cppType(arg.type.name) %}
{% set argName = as_varName(arg.name) %} {% set argName = as_varName(arg.name) %}
{% if arg.type.category in ["enum", "bitmask"] %} {% if arg.type.category in ["enum", "bitmask"] %}
MaybeError {{argName}}Valid = Validate{{cppType}}(static_cast<nxt::{{cppType}}>({{argName}})); MaybeError {{argName}}Valid = Validate{{cppType}}(static_cast<dawn::{{cppType}}>({{argName}}));
if ({{argName}}Valid.IsError()) { if ({{argName}}Valid.IsError()) {
delete {{argName}}Valid.AcquireError(); delete {{argName}}Valid.AcquireError();
error = true; error = true;
@ -167,9 +167,9 @@ namespace {{namespace}} {
{%- for arg in method.arguments -%} {%- for arg in method.arguments -%}
{%- if not loop.first %}, {% endif -%} {%- if not loop.first %}, {% endif -%}
{%- if arg.type.category in ["enum", "bitmask"] -%} {%- if arg.type.category in ["enum", "bitmask"] -%}
static_cast<nxt::{{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 nxt::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}}) reinterpret_cast<const dawn::{{as_cppType(arg.type.name)}}*>({{as_varName(arg.name)}})
{%- else -%} {%- else -%}
{{as_varName(arg.name)}} {{as_varName(arg.name)}}
{%- endif -%} {%- endif -%}

View File

@ -17,10 +17,10 @@
namespace backend { namespace backend {
{% for type in by_category["enum"] %} {% for type in by_category["enum"] %}
MaybeError Validate{{type.name.CamelCase()}}(nxt::{{as_cppType(type.name)}} value) { MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
switch (value) { switch (value) {
{% for value in type.values %} {% for value in type.values %}
case nxt::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}: case dawn::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}:
return {}; return {};
{% endfor %} {% endfor %}
default: default:
@ -31,8 +31,8 @@ namespace backend {
{% endfor %} {% endfor %}
{% for type in by_category["bitmask"] %} {% for type in by_category["bitmask"] %}
MaybeError Validate{{type.name.CamelCase()}}(nxt::{{as_cppType(type.name)}} value) { MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
if ((value & static_cast<nxt::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) { if ((value & static_cast<dawn::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
return {}; return {};
} }
DAWN_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}"); DAWN_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}");

View File

@ -23,7 +23,7 @@ namespace backend {
// Helper functions to check the value of enums and bitmasks // Helper functions to check the value of enums and bitmasks
{% for type in by_category["enum"] + by_category["bitmask"] %} {% for type in by_category["enum"] + by_category["bitmask"] %}
MaybeError Validate{{type.name.CamelCase()}}(nxt::{{as_cppType(type.name)}} value); MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value);
{% endfor %} {% endfor %}
} // namespace backend } // namespace backend

View File

@ -24,7 +24,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace nxt { namespace wire { namespace dawn { namespace wire {
//* Client side implementation of the API, will serialize everything to memory to send to the server side. //* Client side implementation of the API, will serialize everything to memory to send to the server side.
namespace client { namespace client {
@ -673,4 +673,4 @@ namespace nxt { namespace wire {
return new client::Client(clientDevice); return new client::Client(clientDevice);
} }
}} // namespace nxt::wire }} // namespace dawn::wire

View File

@ -258,7 +258,7 @@
} }
{% endmacro %} {% endmacro %}
namespace nxt { namespace wire { namespace dawn { namespace wire {
// Macro to simplify error handling, similar to DAWN_TRY but for DeserializeResult. // Macro to simplify error handling, similar to DAWN_TRY but for DeserializeResult.
#define DESERIALIZE_TRY(EXPR) \ #define DESERIALIZE_TRY(EXPR) \
@ -344,4 +344,4 @@ namespace nxt { namespace wire {
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
}} // namespace nxt::wire }} // namespace dawn::wire

View File

@ -15,7 +15,7 @@
#ifndef WIRE_WIRECMD_AUTOGEN_H_ #ifndef WIRE_WIRECMD_AUTOGEN_H_
#define WIRE_WIRECMD_AUTOGEN_H_ #define WIRE_WIRECMD_AUTOGEN_H_
namespace nxt { namespace wire { namespace dawn { namespace wire {
using ObjectId = uint32_t; using ObjectId = uint32_t;
using ObjectSerial = uint32_t; using ObjectSerial = uint32_t;
@ -140,6 +140,6 @@ namespace nxt { namespace wire {
}; };
{% endfor %} {% endfor %}
}} // namespace nxt::wire }} // namespace dawn::wire
#endif // WIRE_WIRECMD_AUTOGEN_H_ #endif // WIRE_WIRECMD_AUTOGEN_H_

View File

@ -22,7 +22,7 @@
#include <cstring> #include <cstring>
#include <vector> #include <vector>
namespace nxt { namespace wire { namespace dawn { namespace wire {
namespace server { namespace server {
class Server; class Server;
@ -626,4 +626,4 @@ namespace nxt { namespace wire {
return new server::Server(device, procs, serializer); return new server::Server(device, procs, serializer);
} }
}} // namespace nxt::wire }} // namespace dawn::wire

View File

@ -17,7 +17,7 @@
#include <type_traits> #include <type_traits>
namespace nxt { namespace dawn {
// std::underlying_type doesn't work in old GLIBC still used in Chrome // std::underlying_type doesn't work in old GLIBC still used in Chrome
#define CR_GLIBCXX_4_7_0 20120322 #define CR_GLIBCXX_4_7_0 20120322
@ -157,6 +157,6 @@ namespace nxt {
l = l ^ r; l = l ^ r;
return l; return l;
} }
} // namespace nxt } // namespace dawn
#endif // NXT_ENUM_CLASS_BITMASKS_H_ #endif // NXT_ENUM_CLASS_BITMASKS_H_

View File

@ -66,7 +66,7 @@ namespace detail {
class Expectation; class Expectation;
} }
namespace nxt { namespace wire { namespace dawn { namespace wire {
class CommandHandler; class CommandHandler;
class TerribleCommandBuffer; class TerribleCommandBuffer;
}} // namespace dawn::wire }} // namespace dawn::wire

View File

@ -16,7 +16,7 @@
#include "dawn/EnumClassBitmasks.h" #include "dawn/EnumClassBitmasks.h"
namespace nxt { namespace dawn {
enum class Color : uint32_t { enum class Color : uint32_t {
R = 1, R = 1,
@ -90,4 +90,4 @@ namespace nxt {
ASSERT_FALSE(HasZeroOrOneBits(static_cast<Color>(Color::B | Color::A))); ASSERT_FALSE(HasZeroOrOneBits(static_cast<Color>(Color::B | Color::A)));
} }
} } // namespace dawn

View File

@ -20,7 +20,7 @@
#include "wire/Wire.h" #include "wire/Wire.h"
using namespace testing; using namespace testing;
using namespace nxt::wire; using namespace dawn::wire;
// Definition of a "Lambda predicate matcher" for GMock to allow checking deep structures // Definition of a "Lambda predicate matcher" for GMock to allow checking deep structures
// are passed correctly by the wire. // are passed correctly by the wire.

View File

@ -25,21 +25,21 @@
namespace utils { namespace utils {
void FillShaderModuleBuilder(const nxt::ShaderModuleBuilder& builder, void FillShaderModuleBuilder(const dawn::ShaderModuleBuilder& builder,
nxt::ShaderStage stage, dawn::ShaderStage stage,
const char* source) { const char* source) {
shaderc::Compiler compiler; shaderc::Compiler compiler;
shaderc::CompileOptions options; shaderc::CompileOptions options;
shaderc_shader_kind kind; shaderc_shader_kind kind;
switch (stage) { switch (stage) {
case nxt::ShaderStage::Vertex: case dawn::ShaderStage::Vertex:
kind = shaderc_glsl_vertex_shader; kind = shaderc_glsl_vertex_shader;
break; break;
case nxt::ShaderStage::Fragment: case dawn::ShaderStage::Fragment:
kind = shaderc_glsl_fragment_shader; kind = shaderc_glsl_fragment_shader;
break; break;
case nxt::ShaderStage::Compute: case dawn::ShaderStage::Compute:
kind = shaderc_glsl_compute_shader; kind = shaderc_glsl_compute_shader;
break; break;
default: default:
@ -89,67 +89,67 @@ namespace utils {
#endif #endif
} }
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
nxt::ShaderStage stage, dawn::ShaderStage stage,
const char* source) { const char* source) {
nxt::ShaderModuleBuilder builder = device.CreateShaderModuleBuilder(); dawn::ShaderModuleBuilder builder = device.CreateShaderModuleBuilder();
FillShaderModuleBuilder(builder, stage, source); FillShaderModuleBuilder(builder, stage, source);
return builder.GetResult(); return builder.GetResult();
} }
nxt::Buffer CreateBufferFromData(const nxt::Device& device, dawn::Buffer CreateBufferFromData(const dawn::Device& device,
const void* data, const void* data,
uint32_t size, uint32_t size,
nxt::BufferUsageBit usage) { dawn::BufferUsageBit usage) {
nxt::Buffer buffer = device.CreateBufferBuilder() dawn::Buffer buffer = device.CreateBufferBuilder()
.SetAllowedUsage(nxt::BufferUsageBit::TransferDst | usage) .SetAllowedUsage(dawn::BufferUsageBit::TransferDst | usage)
.SetSize(size) .SetSize(size)
.GetResult(); .GetResult();
buffer.SetSubData(0, size, reinterpret_cast<const uint8_t*>(data)); buffer.SetSubData(0, size, reinterpret_cast<const uint8_t*>(data));
return buffer; return buffer;
} }
BasicRenderPass CreateBasicRenderPass(const nxt::Device& device, BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
uint32_t width, uint32_t width,
uint32_t height) { uint32_t height) {
BasicRenderPass result; BasicRenderPass result;
result.width = width; result.width = width;
result.height = height; result.height = height;
result.colorFormat = nxt::TextureFormat::R8G8B8A8Unorm; result.colorFormat = dawn::TextureFormat::R8G8B8A8Unorm;
result.color = device.CreateTextureBuilder() result.color = device.CreateTextureBuilder()
.SetDimension(nxt::TextureDimension::e2D) .SetDimension(dawn::TextureDimension::e2D)
.SetExtent(width, height, 1) .SetExtent(width, height, 1)
.SetFormat(result.colorFormat) .SetFormat(result.colorFormat)
.SetMipLevels(1) .SetMipLevels(1)
.SetAllowedUsage(nxt::TextureUsageBit::OutputAttachment | .SetAllowedUsage(dawn::TextureUsageBit::OutputAttachment |
nxt::TextureUsageBit::TransferSrc) dawn::TextureUsageBit::TransferSrc)
.GetResult(); .GetResult();
nxt::TextureView colorView = result.color.CreateTextureViewBuilder().GetResult(); dawn::TextureView colorView = result.color.CreateTextureViewBuilder().GetResult();
result.renderPassInfo = device.CreateRenderPassDescriptorBuilder() result.renderPassInfo = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, colorView, nxt::LoadOp::Clear) .SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
.GetResult(); .GetResult();
return result; return result;
} }
nxt::SamplerDescriptor GetDefaultSamplerDescriptor() { dawn::SamplerDescriptor GetDefaultSamplerDescriptor() {
nxt::SamplerDescriptor desc; dawn::SamplerDescriptor desc;
desc.minFilter = nxt::FilterMode::Linear; desc.minFilter = dawn::FilterMode::Linear;
desc.magFilter = nxt::FilterMode::Linear; desc.magFilter = dawn::FilterMode::Linear;
desc.mipmapFilter = nxt::FilterMode::Linear; desc.mipmapFilter = dawn::FilterMode::Linear;
desc.addressModeU = nxt::AddressMode::Repeat; desc.addressModeU = dawn::AddressMode::Repeat;
desc.addressModeV = nxt::AddressMode::Repeat; desc.addressModeV = dawn::AddressMode::Repeat;
desc.addressModeW = nxt::AddressMode::Repeat; desc.addressModeW = dawn::AddressMode::Repeat;
return desc; return desc;
} }
nxt::PipelineLayout MakeBasicPipelineLayout(const nxt::Device& device, dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
const nxt::BindGroupLayout* bindGroupLayout) { const dawn::BindGroupLayout* bindGroupLayout) {
nxt::PipelineLayoutDescriptor descriptor; dawn::PipelineLayoutDescriptor descriptor;
if (bindGroupLayout) { if (bindGroupLayout) {
descriptor.numBindGroupLayouts = 1; descriptor.numBindGroupLayouts = 1;
descriptor.bindGroupLayouts = bindGroupLayout; descriptor.bindGroupLayouts = bindGroupLayout;
@ -160,18 +160,18 @@ namespace utils {
return device.CreatePipelineLayout(&descriptor); return device.CreatePipelineLayout(&descriptor);
} }
nxt::BindGroupLayout MakeBindGroupLayout( dawn::BindGroupLayout MakeBindGroupLayout(
const nxt::Device& device, const dawn::Device& device,
std::initializer_list<nxt::BindGroupBinding> bindingsInitializer) { std::initializer_list<dawn::BindGroupBinding> bindingsInitializer) {
std::vector<nxt::BindGroupBinding> bindings; std::vector<dawn::BindGroupBinding> bindings;
nxt::ShaderStageBit kNoStages{}; dawn::ShaderStageBit kNoStages{};
for (const nxt::BindGroupBinding& binding : bindingsInitializer) { for (const dawn::BindGroupBinding& binding : bindingsInitializer) {
if (binding.visibility != kNoStages) { if (binding.visibility != kNoStages) {
bindings.push_back(binding); bindings.push_back(binding);
} }
} }
nxt::BindGroupLayoutDescriptor descriptor; dawn::BindGroupLayoutDescriptor descriptor;
descriptor.numBindings = static_cast<uint32_t>(bindings.size()); descriptor.numBindings = static_cast<uint32_t>(bindings.size());
descriptor.bindings = bindings.data(); descriptor.bindings = bindings.data();
return device.CreateBindGroupLayout(&descriptor); return device.CreateBindGroupLayout(&descriptor);

View File

@ -18,20 +18,20 @@
namespace utils { namespace utils {
void FillShaderModuleBuilder(const nxt::ShaderModuleBuilder& builder, void FillShaderModuleBuilder(const dawn::ShaderModuleBuilder& builder,
nxt::ShaderStage stage, dawn::ShaderStage stage,
const char* source); const char* source);
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
nxt::ShaderStage stage, dawn::ShaderStage stage,
const char* source); const char* source);
nxt::Buffer CreateBufferFromData(const nxt::Device& device, dawn::Buffer CreateBufferFromData(const dawn::Device& device,
const void* data, const void* data,
uint32_t size, uint32_t size,
nxt::BufferUsageBit usage); dawn::BufferUsageBit usage);
template <typename T> template <typename T>
nxt::Buffer CreateBufferFromData(const nxt::Device& device, dawn::Buffer CreateBufferFromData(const dawn::Device& device,
nxt::BufferUsageBit usage, dawn::BufferUsageBit usage,
std::initializer_list<T> data) { std::initializer_list<T> data) {
return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage); return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage);
} }
@ -39,19 +39,19 @@ namespace utils {
struct BasicRenderPass { struct BasicRenderPass {
uint32_t width; uint32_t width;
uint32_t height; uint32_t height;
nxt::Texture color; dawn::Texture color;
nxt::TextureFormat colorFormat; dawn::TextureFormat colorFormat;
nxt::RenderPassDescriptor renderPassInfo; dawn::RenderPassDescriptor renderPassInfo;
}; };
BasicRenderPass CreateBasicRenderPass(const nxt::Device& device, BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
uint32_t width, uint32_t width,
uint32_t height); uint32_t height);
nxt::SamplerDescriptor GetDefaultSamplerDescriptor(); dawn::SamplerDescriptor GetDefaultSamplerDescriptor();
nxt::PipelineLayout MakeBasicPipelineLayout(const nxt::Device& device, dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
const nxt::BindGroupLayout* bindGroupLayout); const dawn::BindGroupLayout* bindGroupLayout);
nxt::BindGroupLayout MakeBindGroupLayout( dawn::BindGroupLayout MakeBindGroupLayout(
const nxt::Device& device, const dawn::Device& device,
std::initializer_list<nxt::BindGroupBinding> bindingsInitializer); std::initializer_list<dawn::BindGroupBinding> bindingsInitializer);
} // namespace utils } // namespace utils

View File

@ -16,7 +16,7 @@
#include "common/Assert.h" #include "common/Assert.h"
namespace nxt { namespace wire { namespace dawn { namespace wire {
TerribleCommandBuffer::TerribleCommandBuffer() { TerribleCommandBuffer::TerribleCommandBuffer() {
} }
@ -56,4 +56,4 @@ namespace nxt { namespace wire {
return success; return success;
} }
}} // namespace nxt::wire }} // namespace dawn::wire

View File

@ -19,7 +19,7 @@
#include "wire/Wire.h" #include "wire/Wire.h"
namespace nxt { namespace wire { namespace dawn { namespace wire {
class TerribleCommandBuffer : public CommandSerializer { class TerribleCommandBuffer : public CommandSerializer {
public: public:
@ -37,6 +37,6 @@ namespace nxt { namespace wire {
char mBuffer[10000000]; char mBuffer[10000000];
}; };
}} // namespace nxt::wire }} // namespace dawn::wire
#endif // WIRE_TERRIBLE_COMMAND_BUFFER_H_ #endif // WIRE_TERRIBLE_COMMAND_BUFFER_H_

View File

@ -19,7 +19,7 @@
#include "dawn/dawn.h" #include "dawn/dawn.h"
namespace nxt { namespace wire { namespace dawn { namespace wire {
class CommandSerializer { class CommandSerializer {
public: public:
@ -41,6 +41,6 @@ namespace nxt { namespace wire {
const nxtProcTable& procs, const nxtProcTable& procs,
CommandSerializer* serializer); CommandSerializer* serializer);
}} // namespace nxt::wire }} // namespace dawn::wire
#endif // WIRE_WIRE_H_ #endif // WIRE_WIRE_H_

View File

@ -19,7 +19,7 @@
#include "wire/WireCmd_autogen.h" #include "wire/WireCmd_autogen.h"
namespace nxt { namespace wire { namespace dawn { namespace wire {
struct ReturnDeviceErrorCallbackCmd { struct ReturnDeviceErrorCallbackCmd {
wire::ReturnWireCmd commandId = ReturnWireCmd::DeviceErrorCallback; wire::ReturnWireCmd commandId = ReturnWireCmd::DeviceErrorCallback;
@ -63,6 +63,6 @@ namespace nxt { namespace wire {
uint32_t dataLength; uint32_t dataLength;
}; };
}} // namespace nxt::wire }} // namespace dawn::wire
#endif // WIRE_WIRECMD_H_ #endif // WIRE_WIRECMD_H_