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:
```cpp
nxt::Buffer buffer = device.CreateBufferBuilder()
.SetUsage(nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Mapped)
dawn::Buffer buffer = device.CreateBufferBuilder()
.SetUsage(dawn::BufferUsageBit::Uniform | dawn::BufferUsageBit::Mapped)
.SetSize(42)
.GetResult();
```

View File

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

View File

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

View File

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

View File

@ -49,9 +49,9 @@ namespace {{namespace}} {
{%- for arg in method.arguments -%}
{%- if not loop.first %}, {% endif -%}
{%- 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" -%}
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 -%}
{{as_varName(arg.name)}}
{%- endif -%}
@ -85,7 +85,7 @@ namespace {{namespace}} {
{% set cppType = as_cppType(arg.type.name) %}
{% set argName = as_varName(arg.name) %}
{% 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()) {
delete {{argName}}Valid.AcquireError();
error = true;
@ -167,9 +167,9 @@ namespace {{namespace}} {
{%- for arg in method.arguments -%}
{%- if not loop.first %}, {% endif -%}
{%- 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" -%}
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 -%}
{{as_varName(arg.name)}}
{%- endif -%}

View File

@ -17,10 +17,10 @@
namespace backend {
{% 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) {
{% 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 {};
{% endfor %}
default:
@ -31,8 +31,8 @@ namespace backend {
{% endfor %}
{% for type in by_category["bitmask"] %}
MaybeError Validate{{type.name.CamelCase()}}(nxt::{{as_cppType(type.name)}} value) {
if ((value & static_cast<nxt::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
if ((value & static_cast<dawn::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
return {};
}
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
{% 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 %}
} // namespace backend

View File

@ -24,7 +24,7 @@
#include <string>
#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.
namespace client {
@ -673,4 +673,4 @@ namespace nxt { namespace wire {
return new client::Client(clientDevice);
}
}} // namespace nxt::wire
}} // namespace dawn::wire

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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