Remove unnecessary Device forwarding.

This commit is contained in:
Corentin Wallez 2017-06-27 11:10:29 -04:00 committed by Corentin Wallez
parent 59d55dc3ac
commit 2dd73fbc1d
22 changed files with 90 additions and 135 deletions

View File

@ -26,7 +26,7 @@ namespace backend {
// PipelineBase // PipelineBase
PipelineBase::PipelineBase(PipelineBuilder* builder) PipelineBase::PipelineBase(PipelineBuilder* builder)
: device(builder->device), stageMask(builder->stageMask), layout(std::move(builder->layout)), : stageMask(builder->stageMask), layout(std::move(builder->layout)),
renderPass(std::move(builder->renderPass)), subpass(builder->subpass), renderPass(std::move(builder->renderPass)), subpass(builder->subpass),
inputState(std::move(builder->inputState)), depthStencilState(std::move(builder->depthStencilState)) { inputState(std::move(builder->inputState)), depthStencilState(std::move(builder->depthStencilState)) {

View File

@ -53,8 +53,6 @@ namespace backend {
bool IsCompute() const; bool IsCompute() const;
private: private:
DeviceBase* device;
nxt::ShaderStageBit stageMask; nxt::ShaderStageBit stageMask;
Ref<PipelineLayoutBase> layout; Ref<PipelineLayoutBase> layout;
Ref<RenderPassBase> renderPass; Ref<RenderPassBase> renderPass;

View File

@ -26,7 +26,7 @@ namespace metal {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandBufferBuilder* builder); CommandBuffer(CommandBufferBuilder* builder);
~CommandBuffer(); ~CommandBuffer();
void FillCommands(id<MTLCommandBuffer> commandBuffer); void FillCommands(id<MTLCommandBuffer> commandBuffer);

View File

@ -119,8 +119,9 @@ namespace metal {
}; };
} }
CommandBuffer::CommandBuffer(Device* device, CommandBufferBuilder* builder) CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
: CommandBufferBase(builder), device(device), commands(builder->AcquireCommands()) { : CommandBufferBase(builder), device(ToBackend(builder->GetDevice())),
commands(builder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -139,32 +139,23 @@ namespace metal {
class BindGroup : public BindGroupBase { class BindGroup : public BindGroupBase {
public: public:
BindGroup(Device* device, BindGroupBuilder* builder); BindGroup(BindGroupBuilder* builder);
private:
Device* device;
}; };
class BindGroupLayout : public BindGroupLayoutBase { class BindGroupLayout : public BindGroupLayoutBase {
public: public:
BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder); BindGroupLayout(BindGroupLayoutBuilder* builder);
private:
Device* device;
}; };
class Framebuffer : public FramebufferBase { class Framebuffer : public FramebufferBase {
public: public:
Framebuffer(Device* device, FramebufferBuilder* builder); Framebuffer(FramebufferBuilder* builder);
~Framebuffer(); ~Framebuffer();
private:
Device* device;
}; };
class Queue : public QueueBase { class Queue : public QueueBase {
public: public:
Queue(Device* device, QueueBuilder* builder); Queue(QueueBuilder* builder);
~Queue(); ~Queue();
id<MTLCommandQueue> GetMTLCommandQueue(); id<MTLCommandQueue> GetMTLCommandQueue();
@ -173,17 +164,13 @@ namespace metal {
void Submit(uint32_t numCommands, CommandBuffer* const * commands); void Submit(uint32_t numCommands, CommandBuffer* const * commands);
private: private:
Device* device;
id<MTLCommandQueue> commandQueue = nil; id<MTLCommandQueue> commandQueue = nil;
}; };
class RenderPass : public RenderPassBase { class RenderPass : public RenderPassBase {
public: public:
RenderPass(Device* device, RenderPassBuilder* builder); RenderPass(RenderPassBuilder* builder);
~RenderPass(); ~RenderPass();
private:
Device* device;
}; };
} }

View File

@ -82,10 +82,10 @@ namespace metal {
} }
BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) { BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
return new BindGroup(this, builder); return new BindGroup(builder);
} }
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) { BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
return new BindGroupLayout(this, builder); return new BindGroupLayout(builder);
} }
BufferBase* Device::CreateBuffer(BufferBuilder* builder) { BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
return new Buffer(builder); return new Buffer(builder);
@ -94,7 +94,7 @@ namespace metal {
return new BufferView(builder); return new BufferView(builder);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) { CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
return new CommandBuffer(this, builder); return new CommandBuffer(builder);
} }
DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) { DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
return new DepthStencilState(builder); return new DepthStencilState(builder);
@ -103,7 +103,7 @@ namespace metal {
return new InputState(builder); return new InputState(builder);
} }
FramebufferBase* Device::CreateFramebuffer(FramebufferBuilder* builder) { FramebufferBase* Device::CreateFramebuffer(FramebufferBuilder* builder) {
return new Framebuffer(this, builder); return new Framebuffer(builder);
} }
PipelineBase* Device::CreatePipeline(PipelineBuilder* builder) { PipelineBase* Device::CreatePipeline(PipelineBuilder* builder) {
return new Pipeline(builder); return new Pipeline(builder);
@ -112,10 +112,10 @@ namespace metal {
return new PipelineLayout(builder); return new PipelineLayout(builder);
} }
QueueBase* Device::CreateQueue(QueueBuilder* builder) { QueueBase* Device::CreateQueue(QueueBuilder* builder) {
return new Queue(this, builder); return new Queue(builder);
} }
RenderPassBase* Device::CreateRenderPass(RenderPassBuilder* builder) { RenderPassBase* Device::CreateRenderPass(RenderPassBuilder* builder) {
return new RenderPass(this, builder); return new RenderPass(builder);
} }
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) { SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
return new Sampler(builder); return new Sampler(builder);
@ -251,20 +251,20 @@ namespace metal {
// Bind Group // Bind Group
BindGroup::BindGroup(Device* device, BindGroupBuilder* builder) BindGroup::BindGroup(BindGroupBuilder* builder)
: BindGroupBase(builder), device(device) { : BindGroupBase(builder) {
} }
// Bind Group Layout // Bind Group Layout
BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder) BindGroupLayout::BindGroupLayout(BindGroupLayoutBuilder* builder)
: BindGroupLayoutBase(builder), device(device) { : BindGroupLayoutBase(builder) {
} }
// Framebuffer // Framebuffer
Framebuffer::Framebuffer(Device* device, FramebufferBuilder* builder) Framebuffer::Framebuffer(FramebufferBuilder* builder)
: FramebufferBase(builder), device(device) { : FramebufferBase(builder) {
} }
Framebuffer::~Framebuffer() { Framebuffer::~Framebuffer() {
@ -272,8 +272,9 @@ namespace metal {
// Queue // Queue
Queue::Queue(Device* device, QueueBuilder* builder) Queue::Queue(QueueBuilder* builder)
: QueueBase(builder), device(device) { : QueueBase(builder) {
Device* device = ToBackend(builder->GetDevice());
commandQueue = [device->GetMTLDevice() newCommandQueue]; commandQueue = [device->GetMTLDevice() newCommandQueue];
} }
@ -299,8 +300,8 @@ namespace metal {
// RenderPass // RenderPass
RenderPass::RenderPass(Device* device, RenderPassBuilder* builder) RenderPass::RenderPass(RenderPassBuilder* builder)
: RenderPassBase(builder), device(device) { : RenderPassBase(builder) {
} }
RenderPass::~RenderPass() { RenderPass::~RenderPass() {

View File

@ -27,8 +27,8 @@
namespace backend { namespace backend {
namespace opengl { namespace opengl {
CommandBuffer::CommandBuffer(Device* device, CommandBufferBuilder* builder) CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
: CommandBufferBase(builder), device(device), commands(builder->AcquireCommands()) { : CommandBufferBase(builder), commands(builder->AcquireCommands()) {
} }
CommandBuffer::~CommandBuffer() { CommandBuffer::~CommandBuffer() {

View File

@ -25,13 +25,12 @@ namespace opengl {
class CommandBuffer : public CommandBufferBase { class CommandBuffer : public CommandBufferBase {
public: public:
CommandBuffer(Device* device, CommandBufferBuilder* builder); CommandBuffer(CommandBufferBuilder* builder);
~CommandBuffer(); ~CommandBuffer();
void Execute(); void Execute();
private: private:
Device* device;
CommandIterator commands; CommandIterator commands;
}; };

View File

@ -64,8 +64,8 @@ namespace opengl {
} }
} }
DepthStencilState::DepthStencilState(Device* device, DepthStencilStateBuilder* builder) DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
: DepthStencilStateBase(builder), device(device) { : DepthStencilStateBase(builder) {
} }
void DepthStencilState::ApplyNow(PersistentPipelineState &persistentPipelineState) const { void DepthStencilState::ApplyNow(PersistentPipelineState &persistentPipelineState) const {

View File

@ -25,12 +25,9 @@ namespace opengl {
class DepthStencilState : public DepthStencilStateBase { class DepthStencilState : public DepthStencilStateBase {
public: public:
DepthStencilState(Device* device, DepthStencilStateBuilder* builder); DepthStencilState(DepthStencilStateBuilder* builder);
void ApplyNow(PersistentPipelineState &persistentPipelineState) const; void ApplyNow(PersistentPipelineState &persistentPipelineState) const;
private:
Device* device;
}; };
} }

View File

@ -49,52 +49,52 @@ namespace opengl {
// Device // Device
BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) { BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
return new BindGroup(this, builder); return new BindGroup(builder);
} }
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) { BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
return new BindGroupLayout(this, builder); return new BindGroupLayout(builder);
} }
BufferBase* Device::CreateBuffer(BufferBuilder* builder) { BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
return new Buffer(this, builder); return new Buffer(builder);
} }
BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) { BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
return new BufferView(this, builder); return new BufferView(builder);
} }
CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) { CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
return new CommandBuffer(this, builder); return new CommandBuffer(builder);
} }
DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) { DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
return new DepthStencilState(this, builder); return new DepthStencilState(builder);
} }
InputStateBase* Device::CreateInputState(InputStateBuilder* builder) { InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
return new InputState(this, builder); return new InputState(builder);
} }
FramebufferBase* Device::CreateFramebuffer(FramebufferBuilder* builder) { FramebufferBase* Device::CreateFramebuffer(FramebufferBuilder* builder) {
return new Framebuffer(this, builder); return new Framebuffer(builder);
} }
PipelineBase* Device::CreatePipeline(PipelineBuilder* builder) { PipelineBase* Device::CreatePipeline(PipelineBuilder* builder) {
return new Pipeline(this, builder); return new Pipeline(builder);
} }
PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) { PipelineLayoutBase* Device::CreatePipelineLayout(PipelineLayoutBuilder* builder) {
return new PipelineLayout(this, builder); return new PipelineLayout(builder);
} }
QueueBase* Device::CreateQueue(QueueBuilder* builder) { QueueBase* Device::CreateQueue(QueueBuilder* builder) {
return new Queue(this, builder); return new Queue(builder);
} }
RenderPassBase* Device::CreateRenderPass(RenderPassBuilder* builder) { RenderPassBase* Device::CreateRenderPass(RenderPassBuilder* builder) {
return new RenderPass(this, builder); return new RenderPass(builder);
} }
SamplerBase* Device::CreateSampler(SamplerBuilder* builder) { SamplerBase* Device::CreateSampler(SamplerBuilder* builder) {
return new Sampler(this, builder); return new Sampler(builder);
} }
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) { ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
return new ShaderModule(this, builder); return new ShaderModule(builder);
} }
TextureBase* Device::CreateTexture(TextureBuilder* builder) { TextureBase* Device::CreateTexture(TextureBuilder* builder) {
return new Texture(this, builder); return new Texture(builder);
} }
TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) { TextureViewBase* Device::CreateTextureView(TextureViewBuilder* builder) {
return new TextureView(this, builder); return new TextureView(builder);
} }
void Device::TickImpl() { void Device::TickImpl() {
@ -108,20 +108,20 @@ namespace opengl {
// Bind Group // Bind Group
BindGroup::BindGroup(Device* device, BindGroupBuilder* builder) BindGroup::BindGroup(BindGroupBuilder* builder)
: BindGroupBase(builder), device(device) { : BindGroupBase(builder) {
} }
// Bind Group Layout // Bind Group Layout
BindGroupLayout::BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder) BindGroupLayout::BindGroupLayout(BindGroupLayoutBuilder* builder)
: BindGroupLayoutBase(builder), device(device) { : BindGroupLayoutBase(builder) {
} }
// Buffer // Buffer
Buffer::Buffer(Device* device, BufferBuilder* builder) Buffer::Buffer(BufferBuilder* builder)
: BufferBase(builder), device(device) { : BufferBase(builder) {
glGenBuffers(1, &buffer); glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, GetSize(), nullptr, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, GetSize(), nullptr, GL_STATIC_DRAW);
@ -149,14 +149,14 @@ namespace opengl {
// BufferView // BufferView
BufferView::BufferView(Device* device, BufferViewBuilder* builder) BufferView::BufferView(BufferViewBuilder* builder)
: BufferViewBase(builder), device(device) { : BufferViewBase(builder) {
} }
// InputState // InputState
InputState::InputState(Device* device, InputStateBuilder* builder) InputState::InputState(InputStateBuilder* builder)
: InputStateBase(builder), device(device) { : InputStateBase(builder) {
glGenVertexArrays(1, &vertexArrayObject); glGenVertexArrays(1, &vertexArrayObject);
glBindVertexArray(vertexArrayObject); glBindVertexArray(vertexArrayObject);
auto& attributesSetMask = GetAttributesSetMask(); auto& attributesSetMask = GetAttributesSetMask();
@ -193,14 +193,14 @@ namespace opengl {
// Framebuffer // Framebuffer
Framebuffer::Framebuffer(Device* device, FramebufferBuilder* builder) Framebuffer::Framebuffer(FramebufferBuilder* builder)
: FramebufferBase(builder), device(device) { : FramebufferBase(builder) {
} }
// Queue // Queue
Queue::Queue(Device* device, QueueBuilder* builder) Queue::Queue(QueueBuilder* builder)
: QueueBase(builder), device(device) { : QueueBase(builder) {
} }
void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) { void Queue::Submit(uint32_t numCommands, CommandBuffer* const * commands) {
@ -211,8 +211,8 @@ namespace opengl {
// RenderPass // RenderPass
RenderPass::RenderPass(Device* device, RenderPassBuilder* builder) RenderPass::RenderPass(RenderPassBuilder* builder)
: RenderPassBase(builder), device(device) { : RenderPassBase(builder) {
} }
} }

View File

@ -106,23 +106,17 @@ namespace opengl {
class BindGroup : public BindGroupBase { class BindGroup : public BindGroupBase {
public: public:
BindGroup(Device* device, BindGroupBuilder* builder); BindGroup(BindGroupBuilder* builder);
private:
Device* device;
}; };
class BindGroupLayout : public BindGroupLayoutBase { class BindGroupLayout : public BindGroupLayoutBase {
public: public:
BindGroupLayout(Device* device, BindGroupLayoutBuilder* builder); BindGroupLayout(BindGroupLayoutBuilder* builder);
private:
Device* device;
}; };
class Buffer : public BufferBase { class Buffer : public BufferBase {
public: public:
Buffer(Device* device, BufferBuilder* builder); Buffer(BufferBuilder* builder);
GLuint GetHandle() const; GLuint GetHandle() const;
@ -132,53 +126,39 @@ namespace opengl {
void UnmapImpl() override; void UnmapImpl() override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override; void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override;
Device* device;
GLuint buffer = 0; GLuint buffer = 0;
}; };
class BufferView : public BufferViewBase { class BufferView : public BufferViewBase {
public: public:
BufferView(Device* device, BufferViewBuilder* builder); BufferView(BufferViewBuilder* builder);
private:
Device* device;
}; };
class Framebuffer : public FramebufferBase { class Framebuffer : public FramebufferBase {
public: public:
Framebuffer(Device* device, FramebufferBuilder* builder); Framebuffer(FramebufferBuilder* builder);
private:
Device* device;
}; };
class InputState : public InputStateBase { class InputState : public InputStateBase {
public: public:
InputState(Device* device, InputStateBuilder* builder); InputState(InputStateBuilder* builder);
GLuint GetVAO(); GLuint GetVAO();
private: private:
Device* device;
GLuint vertexArrayObject; GLuint vertexArrayObject;
}; };
class Queue : public QueueBase { class Queue : public QueueBase {
public: public:
Queue(Device* device, QueueBuilder* builder); Queue(QueueBuilder* builder);
// NXT API // NXT API
void Submit(uint32_t numCommands, CommandBuffer* const * commands); void Submit(uint32_t numCommands, CommandBuffer* const * commands);
private:
Device* device;
}; };
class RenderPass : public RenderPassBase { class RenderPass : public RenderPassBase {
public: public:
RenderPass(Device* device, RenderPassBuilder* builder); RenderPass(RenderPassBuilder* builder);
private:
Device* device;
}; };
} }

View File

@ -41,7 +41,7 @@ namespace opengl {
} }
Pipeline::Pipeline(Device* device, PipelineBuilder* builder) : PipelineBase(builder), device(device) { Pipeline::Pipeline(PipelineBuilder* builder) : PipelineBase(builder) {
auto CreateShader = [](GLenum type, const char* source) -> GLuint { auto CreateShader = [](GLenum type, const char* source) -> GLuint {
GLuint shader = glCreateShader(type); GLuint shader = glCreateShader(type);
glShaderSource(shader, 1, &source, nullptr); glShaderSource(shader, 1, &source, nullptr);

View File

@ -30,7 +30,7 @@ namespace opengl {
class Pipeline : public PipelineBase { class Pipeline : public PipelineBase {
public: public:
Pipeline(Device* device, PipelineBuilder* builder); Pipeline(PipelineBuilder* builder);
using GLPushConstantInfo = std::array<GLint, kMaxPushConstants>; using GLPushConstantInfo = std::array<GLint, kMaxPushConstants>;
using BindingLocations = std::array<std::array<GLint, kMaxBindingsPerGroup>, kMaxBindGroups>; using BindingLocations = std::array<std::array<GLint, kMaxBindingsPerGroup>, kMaxBindGroups>;
@ -47,7 +47,6 @@ namespace opengl {
PerStage<GLPushConstantInfo> glPushConstants; PerStage<GLPushConstantInfo> glPushConstants;
std::vector<std::vector<GLuint>> unitsForSamplers; std::vector<std::vector<GLuint>> unitsForSamplers;
std::vector<std::vector<GLuint>> unitsForTextures; std::vector<std::vector<GLuint>> unitsForTextures;
Device* device;
}; };
} }

View File

@ -19,8 +19,8 @@
namespace backend { namespace backend {
namespace opengl { namespace opengl {
PipelineLayout::PipelineLayout(Device* device, PipelineLayoutBuilder* builder) PipelineLayout::PipelineLayout(PipelineLayoutBuilder* builder)
: PipelineLayoutBase(builder), device(device) { : PipelineLayoutBase(builder) {
GLuint uboIndex = 0; GLuint uboIndex = 0;
GLuint samplerIndex = 0; GLuint samplerIndex = 0;
GLuint sampledTextureIndex = 0; GLuint sampledTextureIndex = 0;

View File

@ -26,7 +26,7 @@ namespace opengl {
class PipelineLayout : public PipelineLayoutBase { class PipelineLayout : public PipelineLayoutBase {
public: public:
PipelineLayout(Device* device, PipelineLayoutBuilder* builder); PipelineLayout(PipelineLayoutBuilder* builder);
using BindingIndexInfo = std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>; using BindingIndexInfo = std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>;
const BindingIndexInfo& GetBindingIndexInfo() const; const BindingIndexInfo& GetBindingIndexInfo() const;
@ -36,7 +36,6 @@ namespace opengl {
size_t GetNumSampledTextures() const; size_t GetNumSampledTextures() const;
private: private:
Device* device;
BindingIndexInfo indexInfo; BindingIndexInfo indexInfo;
size_t numSamplers; size_t numSamplers;
size_t numSampledTextures; size_t numSampledTextures;

View File

@ -47,8 +47,8 @@ namespace opengl {
} }
} }
Sampler::Sampler(Device* device, SamplerBuilder* builder) Sampler::Sampler(SamplerBuilder* builder)
: SamplerBase(builder), device(device) { : SamplerBase(builder) {
glGenSamplers(1, &handle); glGenSamplers(1, &handle);
glSamplerParameteri(handle, GL_TEXTURE_MAG_FILTER, MagFilterMode(builder->GetMagFilter())); glSamplerParameteri(handle, GL_TEXTURE_MAG_FILTER, MagFilterMode(builder->GetMagFilter()));
glSamplerParameteri(handle, GL_TEXTURE_MIN_FILTER, MinFilterMode(builder->GetMinFilter(), builder->GetMipMapFilter())); glSamplerParameteri(handle, GL_TEXTURE_MIN_FILTER, MinFilterMode(builder->GetMinFilter(), builder->GetMipMapFilter()));

View File

@ -26,12 +26,11 @@ namespace opengl {
class Sampler : public SamplerBase { class Sampler : public SamplerBase {
public: public:
Sampler(Device* device, SamplerBuilder* builder); Sampler(SamplerBuilder* builder);
GLuint GetHandle() const; GLuint GetHandle() const;
private: private:
Device* device;
GLuint handle; GLuint handle;
}; };

View File

@ -43,8 +43,8 @@ namespace opengl {
return o.str(); return o.str();
} }
ShaderModule::ShaderModule(Device* device, ShaderModuleBuilder* builder) ShaderModule::ShaderModule(ShaderModuleBuilder* builder)
: ShaderModuleBase(builder), device(device) { : ShaderModuleBase(builder) {
spirv_cross::CompilerGLSL compiler(builder->AcquireSpirv()); spirv_cross::CompilerGLSL compiler(builder->AcquireSpirv());
spirv_cross::CompilerGLSL::Options options; spirv_cross::CompilerGLSL::Options options;

View File

@ -41,7 +41,7 @@ namespace opengl {
class ShaderModule : public ShaderModuleBase { class ShaderModule : public ShaderModuleBase {
public: public:
ShaderModule(Device* device, ShaderModuleBuilder* builder); ShaderModule(ShaderModuleBuilder* builder);
using CombinedSamplerInfo = std::vector<CombinedSampler>; using CombinedSamplerInfo = std::vector<CombinedSampler>;
@ -49,7 +49,6 @@ namespace opengl {
const CombinedSamplerInfo& GetCombinedSamplerInfo() const; const CombinedSamplerInfo& GetCombinedSamplerInfo() const;
private: private:
Device* device;
CombinedSamplerInfo combinedInfo; CombinedSamplerInfo combinedInfo;
std::string glslSource; std::string glslSource;
}; };

View File

@ -40,8 +40,8 @@ namespace opengl {
// Texture // Texture
Texture::Texture(Device* device, TextureBuilder* builder) Texture::Texture(TextureBuilder* builder)
: TextureBase(builder), device(device) { : TextureBase(builder) {
target = TargetForDimension(GetDimension()); target = TargetForDimension(GetDimension());
uint32_t width = GetWidth(); uint32_t width = GetWidth();
@ -81,8 +81,8 @@ namespace opengl {
// TextureView // TextureView
TextureView::TextureView(Device* device, TextureViewBuilder* builder) TextureView::TextureView(TextureViewBuilder* builder)
: TextureViewBase(builder), device(device) { : TextureViewBase(builder) {
} }
} }

View File

@ -32,7 +32,7 @@ namespace opengl {
class Texture : public TextureBase { class Texture : public TextureBase {
public: public:
Texture(Device* device, TextureBuilder* builder); Texture(TextureBuilder* builder);
GLuint GetHandle() const; GLuint GetHandle() const;
GLenum GetGLTarget() const; GLenum GetGLTarget() const;
@ -41,17 +41,13 @@ namespace opengl {
private: private:
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override; void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
Device* device;
GLuint handle; GLuint handle;
GLenum target; GLenum target;
}; };
class TextureView : public TextureViewBase { class TextureView : public TextureViewBase {
public: public:
TextureView(Device* device, TextureViewBuilder* builder); TextureView(TextureViewBuilder* builder);
private:
Device* device;
}; };