Format: src/backend/null

This commit is contained in:
Corentin Wallez 2017-11-24 14:13:32 -05:00 committed by Corentin Wallez
parent f58d84d488
commit 1aa4d5604f
2 changed files with 83 additions and 90 deletions

View File

@ -18,8 +18,7 @@
#include <spirv-cross/spirv_cross.hpp> #include <spirv-cross/spirv_cross.hpp>
namespace backend { namespace backend { namespace null {
namespace null {
nxtProcTable GetNonValidatingProcs(); nxtProcTable GetNonValidatingProcs();
nxtProcTable GetValidatingProcs(); nxtProcTable GetValidatingProcs();
@ -122,9 +121,9 @@ namespace null {
uint32_t serial; uint32_t serial;
}; };
Buffer::Buffer(BufferBuilder* builder) Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
: BufferBase(builder) { if (GetAllowedUsage() & (nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::MapRead |
if (GetAllowedUsage() & (nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) { nxt::BufferUsageBit::MapWrite)) {
mBackingData = std::unique_ptr<char[]>(new char[GetSize()]); mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
} }
} }
@ -174,18 +173,16 @@ namespace null {
Command type; Command type;
while (mCommands.NextCommandId(&type)) { while (mCommands.NextCommandId(&type)) {
switch (type) { switch (type) {
case Command::TransitionBufferUsage: case Command::TransitionBufferUsage: {
{ TransitionBufferUsageCmd* cmd =
TransitionBufferUsageCmd* cmd = mCommands.NextCommand<TransitionBufferUsageCmd>(); mCommands.NextCommand<TransitionBufferUsageCmd>();
cmd->buffer->UpdateUsageInternal(cmd->usage); cmd->buffer->UpdateUsageInternal(cmd->usage);
} } break;
break; case Command::TransitionTextureUsage: {
case Command::TransitionTextureUsage: TransitionTextureUsageCmd* cmd =
{ mCommands.NextCommand<TransitionTextureUsageCmd>();
TransitionTextureUsageCmd* cmd = mCommands.NextCommand<TransitionTextureUsageCmd>();
cmd->texture->UpdateUsageInternal(cmd->usage); cmd->texture->UpdateUsageInternal(cmd->usage);
} } break;
break;
default: default:
SkipCommand(&mCommands, type); SkipCommand(&mCommands, type);
break; break;
@ -195,8 +192,7 @@ namespace null {
// Queue // Queue
Queue::Queue(QueueBuilder* builder) Queue::Queue(QueueBuilder* builder) : QueueBase(builder) {
: QueueBase(builder) {
} }
Queue::~Queue() { Queue::~Queue() {
@ -218,8 +214,7 @@ namespace null {
// Texture // Texture
Texture::Texture(TextureBuilder* builder) Texture::Texture(TextureBuilder* builder) : TextureBase(builder) {
: TextureBase(builder) {
} }
Texture::~Texture() { Texture::~Texture() {
@ -230,8 +225,7 @@ namespace null {
// SwapChain // SwapChain
SwapChain::SwapChain(SwapChainBuilder* builder) SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
: SwapChainBase(builder) {
const auto& im = GetImplementation(); const auto& im = GetImplementation();
im.Init(im.userData, nullptr); im.Init(im.userData, nullptr);
} }
@ -242,5 +236,4 @@ namespace null {
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) { TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
return GetDevice()->CreateTexture(builder); return GetDevice()->CreateTexture(builder);
} }
} }} // namespace backend::null
}

View File

@ -17,14 +17,14 @@
#include "nxt/nxtcpp.h" #include "nxt/nxtcpp.h"
#include "backend/Buffer.h"
#include "backend/BindGroup.h" #include "backend/BindGroup.h"
#include "backend/BindGroupLayout.h" #include "backend/BindGroupLayout.h"
#include "backend/BlendState.h" #include "backend/BlendState.h"
#include "backend/Device.h" #include "backend/Buffer.h"
#include "backend/CommandBuffer.h" #include "backend/CommandBuffer.h"
#include "backend/ComputePipeline.h" #include "backend/ComputePipeline.h"
#include "backend/DepthStencilState.h" #include "backend/DepthStencilState.h"
#include "backend/Device.h"
#include "backend/Framebuffer.h" #include "backend/Framebuffer.h"
#include "backend/InputState.h" #include "backend/InputState.h"
#include "backend/PipelineLayout.h" #include "backend/PipelineLayout.h"
@ -37,8 +37,7 @@
#include "backend/Texture.h" #include "backend/Texture.h"
#include "backend/ToBackend.h" #include "backend/ToBackend.h"
namespace backend { namespace backend { namespace null {
namespace null {
using BindGroup = BindGroupBase; using BindGroup = BindGroupBase;
using BindGroupLayout = BindGroupLayoutBase; using BindGroupLayout = BindGroupLayoutBase;
@ -139,7 +138,8 @@ namespace null {
void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override; void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override;
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override; void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
void UnmapImpl() override; void UnmapImpl() override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override; void TransitionUsageImpl(nxt::BufferUsageBit currentUsage,
nxt::BufferUsageBit targetUsage) override;
std::unique_ptr<char[]> mBackingData; std::unique_ptr<char[]> mBackingData;
}; };
@ -169,7 +169,8 @@ namespace null {
Texture(TextureBuilder* builder); Texture(TextureBuilder* builder);
~Texture(); ~Texture();
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override; void TransitionUsageImpl(nxt::TextureUsageBit currentUsage,
nxt::TextureUsageBit targetUsage) override;
}; };
class SwapChain : public SwapChainBase { class SwapChain : public SwapChainBase {
@ -181,7 +182,6 @@ namespace null {
TextureBase* GetNextTextureImpl(TextureBuilder* builder) override; TextureBase* GetNextTextureImpl(TextureBuilder* builder) override;
}; };
} }} // namespace backend::null
}
#endif // BACKEND_NULL_NULLBACKEND_H_ #endif // BACKEND_NULL_NULLBACKEND_H_