Member rename: src/backend/opengl
diff --git a/src/backend/opengl/BufferGL.cpp b/src/backend/opengl/BufferGL.cpp
index 9a0f5db..0086dba 100644
--- a/src/backend/opengl/BufferGL.cpp
+++ b/src/backend/opengl/BufferGL.cpp
@@ -23,17 +23,17 @@
Buffer::Buffer(BufferBuilder* builder)
: BufferBase(builder) {
- glGenBuffers(1, &buffer);
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glGenBuffers(1, &mBuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferData(GL_ARRAY_BUFFER, GetSize(), nullptr, GL_STATIC_DRAW);
}
GLuint Buffer::GetHandle() const {
- return buffer;
+ return mBuffer;
}
void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) {
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferSubData(GL_ARRAY_BUFFER, start * sizeof(uint32_t), count * sizeof(uint32_t), data);
}
@@ -41,13 +41,13 @@
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
// version of OpenGL that would let us map the buffer unsynchronized.
// TODO(cwallez@chromium.org): this crashes on Mac NVIDIA, use GetBufferSubData there instead?
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
CallMapReadCallback(serial, NXT_BUFFER_MAP_READ_STATUS_SUCCESS, data);
}
void Buffer::UnmapImpl() {
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glUnmapBuffer(GL_ARRAY_BUFFER);
}
diff --git a/src/backend/opengl/BufferGL.h b/src/backend/opengl/BufferGL.h
index bcbc2f7..fb589c7 100644
--- a/src/backend/opengl/BufferGL.h
+++ b/src/backend/opengl/BufferGL.h
@@ -36,7 +36,7 @@
void UnmapImpl() override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage, nxt::BufferUsageBit targetUsage) override;
- GLuint buffer = 0;
+ GLuint mBuffer = 0;
};
class BufferView : public BufferViewBase {
diff --git a/src/backend/opengl/CommandBufferGL.cpp b/src/backend/opengl/CommandBufferGL.cpp
index 8379eca..32eead8 100644
--- a/src/backend/opengl/CommandBufferGL.cpp
+++ b/src/backend/opengl/CommandBufferGL.cpp
@@ -61,145 +61,149 @@
//
// This structure tracks the current values of push constants as well as dirty bits for push constants
// that should be applied before the next draw or dispatch.
- struct PushConstantTracker {
- PerStage<std::array<uint32_t, kMaxPushConstants>> values;
- PerStage<std::bitset<kMaxPushConstants>> dirtyBits;
-
- void OnBeginPass() {
- for (auto stage : IterateStages(kAllStages)) {
- values[stage].fill(0);
- // No need to set dirty bits as a pipeline will be set before the next operation
- // using push constants.
- }
- }
-
- void OnSetPushConstants(nxt::ShaderStageBit stages, uint32_t count,
- uint32_t offset, const uint32_t* data) {
- for (auto stage : IterateStages(stages)) {
- memcpy(&values[stage][offset], data, count * sizeof(uint32_t));
-
- // Use 64 bit masks and make sure there are no shift UB
- static_assert(kMaxPushConstants <= 8 * sizeof(unsigned long long) - 1, "");
- dirtyBits[stage] |= ((1ull << count) - 1ull) << offset;
- }
- }
-
- void OnSetPipeline(PipelineBase* pipeline) {
- for (auto stage : IterateStages(kAllStages)) {
- dirtyBits[stage] = pipeline->GetPushConstants(stage).mask;
- }
- }
-
- void Apply(PipelineBase* pipeline, PipelineGL* glPipeline) {
- for (auto stage : IterateStages(kAllStages)) {
- const auto& pushConstants = pipeline->GetPushConstants(stage);
- const auto& glPushConstants = glPipeline->GetGLPushConstants(stage);
-
- for (uint32_t constant : IterateBitSet(dirtyBits[stage] & pushConstants.mask)) {
- GLint location = glPushConstants[constant];
- switch (pushConstants.types[constant]) {
- case PushConstantType::Int:
- glUniform1i(location, *reinterpret_cast<GLint*>(&values[stage][constant]));
- break;
- case PushConstantType::UInt:
- glUniform1ui(location, *reinterpret_cast<GLuint*>(&values[stage][constant]));
- break;
- case PushConstantType::Float:
- glUniform1f(location, *reinterpret_cast<GLfloat*>(&values[stage][constant]));
- break;
- }
+ class PushConstantTracker {
+ public:
+ void OnBeginPass() {
+ for (auto stage : IterateStages(kAllStages)) {
+ mValues[stage].fill(0);
+ // No need to set dirty bits as a pipeline will be set before the next operation
+ // using push constants.
}
-
- dirtyBits[stage].reset();
}
- }
+
+ void OnSetPushConstants(nxt::ShaderStageBit stages, uint32_t count,
+ uint32_t offset, const uint32_t* data) {
+ for (auto stage : IterateStages(stages)) {
+ memcpy(&mValues[stage][offset], data, count * sizeof(uint32_t));
+
+ // Use 64 bit masks and make sure there are no shift UB
+ static_assert(kMaxPushConstants <= 8 * sizeof(unsigned long long) - 1, "");
+ mDirtyBits[stage] |= ((1ull << count) - 1ull) << offset;
+ }
+ }
+
+ void OnSetPipeline(PipelineBase* pipeline) {
+ for (auto stage : IterateStages(kAllStages)) {
+ mDirtyBits[stage] = pipeline->GetPushConstants(stage).mask;
+ }
+ }
+
+ void Apply(PipelineBase* pipeline, PipelineGL* glPipeline) {
+ for (auto stage : IterateStages(kAllStages)) {
+ const auto& pushConstants = pipeline->GetPushConstants(stage);
+ const auto& glPushConstants = glPipeline->GetGLPushConstants(stage);
+
+ for (uint32_t constant : IterateBitSet(mDirtyBits[stage] & pushConstants.mask)) {
+ GLint location = glPushConstants[constant];
+ switch (pushConstants.types[constant]) {
+ case PushConstantType::Int:
+ glUniform1i(location, *reinterpret_cast<GLint*>(&mValues[stage][constant]));
+ break;
+ case PushConstantType::UInt:
+ glUniform1ui(location, *reinterpret_cast<GLuint*>(&mValues[stage][constant]));
+ break;
+ case PushConstantType::Float:
+ glUniform1f(location, *reinterpret_cast<GLfloat*>(&mValues[stage][constant]));
+ break;
+ }
+ }
+
+ mDirtyBits[stage].reset();
+ }
+ }
+
+ private:
+ PerStage<std::array<uint32_t, kMaxPushConstants>> mValues;
+ PerStage<std::bitset<kMaxPushConstants>> mDirtyBits;
};
// Vertex buffers and index buffers are implemented as part of an OpenGL VAO that corresponds to an
// InputState. On the contrary in NXT they are part of the global state. This means that we have to
// re-apply these buffers on an InputState change.
- struct InputBufferTracker {
- bool indexBufferDirty = false;
- Buffer* indexBuffer = nullptr;
-
- std::bitset<kMaxVertexInputs> dirtyVertexBuffers;
- std::array<Buffer*, kMaxVertexInputs> vertexBuffers;
- std::array<uint32_t, kMaxVertexInputs> vertexBufferOffsets;
-
- InputState* lastInputState = nullptr;
-
- void OnBeginPass() {
- // We don't know what happened between this pass and the last one, just reset the
- // input state so everything gets reapplied.
- lastInputState = nullptr;
- }
-
- void OnSetIndexBuffer(BufferBase* buffer) {
- indexBufferDirty = true;
- indexBuffer = ToBackend(buffer);
- }
-
- void OnSetVertexBuffers(uint32_t startSlot, uint32_t count, Ref<BufferBase>* buffers, uint32_t* offsets) {
- for (uint32_t i = 0; i < count; ++i) {
- uint32_t slot = startSlot + i;
- vertexBuffers[slot] = ToBackend(buffers[i].Get());
- vertexBufferOffsets[slot] = offsets[i];
+ class InputBufferTracker {
+ public:
+ void OnBeginPass() {
+ // We don't know what happened between this pass and the last one, just reset the
+ // input state so everything gets reapplied.
+ mLastInputState = nullptr;
}
- // Use 64 bit masks and make sure there are no shift UB
- static_assert(kMaxVertexInputs <= 8 * sizeof(unsigned long long) - 1, "");
- dirtyVertexBuffers |= ((1ull << count) - 1ull) << startSlot;
- }
-
- void OnSetPipeline(RenderPipelineBase* pipeline) {
- InputStateBase* inputState = pipeline->GetInputState();
- if (lastInputState == inputState) {
- return;
+ void OnSetIndexBuffer(BufferBase* buffer) {
+ mIndexBufferDirty = true;
+ mIndexBuffer = ToBackend(buffer);
}
- indexBufferDirty = true;
- dirtyVertexBuffers |= inputState->GetInputsSetMask();
-
- lastInputState = ToBackend(inputState);
- }
-
- void Apply() {
- if (indexBufferDirty && indexBuffer != nullptr) {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer->GetHandle());
- indexBufferDirty = false;
- }
-
- for (uint32_t slot : IterateBitSet(dirtyVertexBuffers & lastInputState->GetInputsSetMask())) {
- for (uint32_t location : IterateBitSet(lastInputState->GetAttributesUsingInput(slot))) {
- auto attribute = lastInputState->GetAttribute(location);
-
- GLuint buffer = vertexBuffers[slot]->GetHandle();
- uint32_t offset = vertexBufferOffsets[slot];
-
- auto input = lastInputState->GetInput(slot);
- auto components = VertexFormatNumComponents(attribute.format);
- auto formatType = VertexFormatType(attribute.format);
-
- glBindBuffer(GL_ARRAY_BUFFER, buffer);
- glVertexAttribPointer(
- location, components, formatType, GL_FALSE,
- input.stride,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset + attribute.offset)));
+ void OnSetVertexBuffers(uint32_t startSlot, uint32_t count, Ref<BufferBase>* buffers, uint32_t* offsets) {
+ for (uint32_t i = 0; i < count; ++i) {
+ uint32_t slot = startSlot + i;
+ mVertexBuffers[slot] = ToBackend(buffers[i].Get());
+ mVertexBufferOffsets[slot] = offsets[i];
}
+
+ // Use 64 bit masks and make sure there are no shift UB
+ static_assert(kMaxVertexInputs <= 8 * sizeof(unsigned long long) - 1, "");
+ mDirtyVertexBuffers |= ((1ull << count) - 1ull) << startSlot;
}
- dirtyVertexBuffers.reset();
- }
+ void OnSetPipeline(RenderPipelineBase* pipeline) {
+ InputStateBase* inputState = pipeline->GetInputState();
+ if (mLastInputState == inputState) {
+ return;
+ }
+
+ mIndexBufferDirty = true;
+ mDirtyVertexBuffers |= inputState->GetInputsSetMask();
+
+ mLastInputState = ToBackend(inputState);
+ }
+
+ void Apply() {
+ if (mIndexBufferDirty && mIndexBuffer != nullptr) {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer->GetHandle());
+ mIndexBufferDirty = false;
+ }
+
+ for (uint32_t slot : IterateBitSet(mDirtyVertexBuffers & mLastInputState->GetInputsSetMask())) {
+ for (uint32_t location : IterateBitSet(mLastInputState->GetAttributesUsingInput(slot))) {
+ auto attribute = mLastInputState->GetAttribute(location);
+
+ GLuint buffer = mVertexBuffers[slot]->GetHandle();
+ uint32_t offset = mVertexBufferOffsets[slot];
+
+ auto input = mLastInputState->GetInput(slot);
+ auto components = VertexFormatNumComponents(attribute.format);
+ auto formatType = VertexFormatType(attribute.format);
+
+ glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glVertexAttribPointer(
+ location, components, formatType, GL_FALSE,
+ input.stride,
+ reinterpret_cast<void*>(static_cast<intptr_t>(offset + attribute.offset)));
+ }
+ }
+
+ mDirtyVertexBuffers.reset();
+ }
+
+ private:
+ bool mIndexBufferDirty = false;
+ Buffer* mIndexBuffer = nullptr;
+
+ std::bitset<kMaxVertexInputs> mDirtyVertexBuffers;
+ std::array<Buffer*, kMaxVertexInputs> mVertexBuffers;
+ std::array<uint32_t, kMaxVertexInputs> mVertexBufferOffsets;
+
+ InputState* mLastInputState = nullptr;
};
}
CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
- : CommandBufferBase(builder), commands(builder->AcquireCommands()) {
+ : CommandBufferBase(builder), mCommands(builder->AcquireCommands()) {
}
CommandBuffer::~CommandBuffer() {
- FreeCommands(&commands);
+ FreeCommands(&mCommands);
}
void CommandBuffer::Execute() {
@@ -220,18 +224,18 @@
uint32_t currentSubpass = 0;
GLuint currentFBO = 0;
- while(commands.NextCommandId(&type)) {
+ while(mCommands.NextCommandId(&type)) {
switch (type) {
case Command::BeginComputePass:
{
- commands.NextCommand<BeginComputePassCmd>();
+ mCommands.NextCommand<BeginComputePassCmd>();
pushConstants.OnBeginPass();
}
break;
case Command::BeginRenderPass:
{
- auto* cmd = commands.NextCommand<BeginRenderPassCmd>();
+ auto* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
currentRenderPass = ToBackend(cmd->renderPass.Get());
currentFramebuffer = ToBackend(cmd->framebuffer.Get());
currentSubpass = 0;
@@ -240,7 +244,7 @@
case Command::BeginRenderSubpass:
{
- commands.NextCommand<BeginRenderSubpassCmd>();
+ mCommands.NextCommand<BeginRenderSubpassCmd>();
pushConstants.OnBeginPass();
inputBuffers.OnBeginPass();
@@ -359,7 +363,7 @@
case Command::CopyBufferToBuffer:
{
- CopyBufferToBufferCmd* copy = commands.NextCommand<CopyBufferToBufferCmd>();
+ CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
auto& src = copy->source;
auto& dst = copy->destination;
@@ -374,7 +378,7 @@
case Command::CopyBufferToTexture:
{
- CopyBufferToTextureCmd* copy = commands.NextCommand<CopyBufferToTextureCmd>();
+ CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
auto& src = copy->source;
auto& dst = copy->destination;
Buffer* buffer = ToBackend(src.buffer.Get());
@@ -398,7 +402,7 @@
case Command::CopyTextureToBuffer:
{
- CopyTextureToBufferCmd* copy = commands.NextCommand<CopyTextureToBufferCmd>();
+ CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
auto& src = copy->source;
auto& dst = copy->destination;
Texture* texture = ToBackend(src.texture.Get());
@@ -431,7 +435,7 @@
case Command::Dispatch:
{
- DispatchCmd* dispatch = commands.NextCommand<DispatchCmd>();
+ DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
pushConstants.Apply(lastPipeline, lastGLPipeline);
glDispatchCompute(dispatch->x, dispatch->y, dispatch->z);
// TODO(cwallez@chromium.org): add barriers to the API
@@ -441,7 +445,7 @@
case Command::DrawArrays:
{
- DrawArraysCmd* draw = commands.NextCommand<DrawArraysCmd>();
+ DrawArraysCmd* draw = mCommands.NextCommand<DrawArraysCmd>();
pushConstants.Apply(lastPipeline, lastGLPipeline);
inputBuffers.Apply();
@@ -458,7 +462,7 @@
case Command::DrawElements:
{
- DrawElementsCmd* draw = commands.NextCommand<DrawElementsCmd>();
+ DrawElementsCmd* draw = mCommands.NextCommand<DrawElementsCmd>();
pushConstants.Apply(lastPipeline, lastGLPipeline);
inputBuffers.Apply();
@@ -483,19 +487,19 @@
case Command::EndComputePass:
{
- commands.NextCommand<EndComputePassCmd>();
+ mCommands.NextCommand<EndComputePassCmd>();
}
break;
case Command::EndRenderPass:
{
- commands.NextCommand<EndRenderPassCmd>();
+ mCommands.NextCommand<EndRenderPassCmd>();
}
break;
case Command::EndRenderSubpass:
{
- commands.NextCommand<EndRenderSubpassCmd>();
+ mCommands.NextCommand<EndRenderSubpassCmd>();
glDeleteFramebuffers(1, ¤tFBO);
currentFBO = 0;
currentSubpass += 1;
@@ -504,7 +508,7 @@
case Command::SetComputePipeline:
{
- SetComputePipelineCmd* cmd = commands.NextCommand<SetComputePipelineCmd>();
+ SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
ToBackend(cmd->pipeline)->ApplyNow();
lastGLPipeline = ToBackend(cmd->pipeline).Get();
lastPipeline = ToBackend(cmd->pipeline).Get();
@@ -514,7 +518,7 @@
case Command::SetRenderPipeline:
{
- SetRenderPipelineCmd* cmd = commands.NextCommand<SetRenderPipelineCmd>();
+ SetRenderPipelineCmd* cmd = mCommands.NextCommand<SetRenderPipelineCmd>();
ToBackend(cmd->pipeline)->ApplyNow(persistentPipelineState);
lastRenderPipeline = ToBackend(cmd->pipeline).Get();
lastGLPipeline = ToBackend(cmd->pipeline).Get();
@@ -527,29 +531,29 @@
case Command::SetPushConstants:
{
- SetPushConstantsCmd* cmd = commands.NextCommand<SetPushConstantsCmd>();
- uint32_t* data = commands.NextData<uint32_t>(cmd->count);
+ SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
+ uint32_t* data = mCommands.NextData<uint32_t>(cmd->count);
pushConstants.OnSetPushConstants(cmd->stages, cmd->count, cmd->offset, data);
}
break;
case Command::SetStencilReference:
{
- SetStencilReferenceCmd* cmd = commands.NextCommand<SetStencilReferenceCmd>();
+ SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
persistentPipelineState.SetStencilReference(cmd->reference);
}
break;
case Command::SetBlendColor:
{
- SetBlendColorCmd* cmd = commands.NextCommand<SetBlendColorCmd>();
+ SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
}
break;
case Command::SetBindGroup:
{
- SetBindGroupCmd* cmd = commands.NextCommand<SetBindGroupCmd>();
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
size_t groupIndex = cmd->index;
BindGroup* group = ToBackend(cmd->group.Get());
@@ -610,7 +614,7 @@
case Command::SetIndexBuffer:
{
- SetIndexBufferCmd* cmd = commands.NextCommand<SetIndexBufferCmd>();
+ SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
indexBufferOffset = cmd->offset;
inputBuffers.OnSetIndexBuffer(cmd->buffer.Get());
}
@@ -618,16 +622,16 @@
case Command::SetVertexBuffers:
{
- SetVertexBuffersCmd* cmd = commands.NextCommand<SetVertexBuffersCmd>();
- auto buffers = commands.NextData<Ref<BufferBase>>(cmd->count);
- auto offsets = commands.NextData<uint32_t>(cmd->count);
+ SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
+ auto offsets = mCommands.NextData<uint32_t>(cmd->count);
inputBuffers.OnSetVertexBuffers(cmd->startSlot, cmd->count, buffers, offsets);
}
break;
case Command::TransitionBufferUsage:
{
- TransitionBufferUsageCmd* cmd = commands.NextCommand<TransitionBufferUsageCmd>();
+ TransitionBufferUsageCmd* cmd = mCommands.NextCommand<TransitionBufferUsageCmd>();
cmd->buffer->UpdateUsageInternal(cmd->usage);
}
@@ -635,7 +639,7 @@
case Command::TransitionTextureUsage:
{
- TransitionTextureUsageCmd* cmd = commands.NextCommand<TransitionTextureUsageCmd>();
+ TransitionTextureUsageCmd* cmd = mCommands.NextCommand<TransitionTextureUsageCmd>();
cmd->texture->UpdateUsageInternal(cmd->usage);
}
diff --git a/src/backend/opengl/CommandBufferGL.h b/src/backend/opengl/CommandBufferGL.h
index 79891de..dcbe06f 100644
--- a/src/backend/opengl/CommandBufferGL.h
+++ b/src/backend/opengl/CommandBufferGL.h
@@ -31,7 +31,7 @@
void Execute();
private:
- CommandIterator commands;
+ CommandIterator mCommands;
};
}
diff --git a/src/backend/opengl/InputStateGL.cpp b/src/backend/opengl/InputStateGL.cpp
index d7aaaff..957d1d0 100644
--- a/src/backend/opengl/InputStateGL.cpp
+++ b/src/backend/opengl/InputStateGL.cpp
@@ -22,8 +22,8 @@
InputState::InputState(InputStateBuilder* builder)
: InputStateBase(builder) {
- glGenVertexArrays(1, &vertexArrayObject);
- glBindVertexArray(vertexArrayObject);
+ glGenVertexArrays(1, &mVertexArrayObject);
+ glBindVertexArray(mVertexArrayObject);
auto& attributesSetMask = GetAttributesSetMask();
for (uint32_t location = 0; location < attributesSetMask.size(); ++location) {
if (!attributesSetMask[location]) {
@@ -58,7 +58,7 @@
}
GLuint InputState::GetVAO() {
- return vertexArrayObject;
+ return mVertexArrayObject;
}
}
diff --git a/src/backend/opengl/InputStateGL.h b/src/backend/opengl/InputStateGL.h
index 098f151..e3401ad 100644
--- a/src/backend/opengl/InputStateGL.h
+++ b/src/backend/opengl/InputStateGL.h
@@ -32,7 +32,7 @@
GLuint GetVAO();
private:
- GLuint vertexArrayObject;
+ GLuint mVertexArrayObject;
std::array<std::bitset<kMaxVertexAttributes>, kMaxVertexInputs> attributesUsingInput;
};
diff --git a/src/backend/opengl/PersistentPipelineStateGL.cpp b/src/backend/opengl/PersistentPipelineStateGL.cpp
index bb81e75..bec9bfa 100644
--- a/src/backend/opengl/PersistentPipelineStateGL.cpp
+++ b/src/backend/opengl/PersistentPipelineStateGL.cpp
@@ -24,36 +24,36 @@
}
void PersistentPipelineState::SetStencilFuncsAndMask(GLenum stencilBackCompareFunction, GLenum stencilFrontCompareFunction, uint32_t stencilReadMask) {
- if (this->stencilBackCompareFunction == stencilBackCompareFunction &&
- this->stencilFrontCompareFunction == stencilFrontCompareFunction &&
- this->stencilReadMask == stencilReadMask) {
+ if (mStencilBackCompareFunction == stencilBackCompareFunction &&
+ mStencilFrontCompareFunction == stencilFrontCompareFunction &&
+ mStencilReadMask == stencilReadMask) {
return;
}
- this->stencilBackCompareFunction = stencilBackCompareFunction;
- this->stencilFrontCompareFunction = stencilFrontCompareFunction;
- this->stencilReadMask = stencilReadMask;
+ mStencilBackCompareFunction = stencilBackCompareFunction;
+ mStencilFrontCompareFunction = stencilFrontCompareFunction;
+ mStencilReadMask = stencilReadMask;
CallGLStencilFunc();
}
void PersistentPipelineState::SetStencilReference(uint32_t stencilReference) {
- if (this->stencilReference == stencilReference) {
+ if (mStencilReference == stencilReference) {
return;
}
- this->stencilReference = stencilReference;
+ mStencilReference = stencilReference;
CallGLStencilFunc();
}
void PersistentPipelineState::CallGLStencilFunc() {
glStencilFuncSeparate(GL_BACK,
- stencilBackCompareFunction,
- stencilReference,
- stencilReadMask);
+ mStencilBackCompareFunction,
+ mStencilReference,
+ mStencilReadMask);
glStencilFuncSeparate(GL_FRONT,
- stencilFrontCompareFunction,
- stencilReference,
- stencilReadMask);
+ mStencilFrontCompareFunction,
+ mStencilReference,
+ mStencilReadMask);
}
}
diff --git a/src/backend/opengl/PersistentPipelineStateGL.h b/src/backend/opengl/PersistentPipelineStateGL.h
index c0b0a30..ef6eddf 100644
--- a/src/backend/opengl/PersistentPipelineStateGL.h
+++ b/src/backend/opengl/PersistentPipelineStateGL.h
@@ -31,10 +31,10 @@
private:
void CallGLStencilFunc();
- GLenum stencilBackCompareFunction = GL_ALWAYS;
- GLenum stencilFrontCompareFunction = GL_ALWAYS;
- GLuint stencilReadMask = 0xffffffff;
- GLuint stencilReference = 0;
+ GLenum mStencilBackCompareFunction = GL_ALWAYS;
+ GLenum mStencilFrontCompareFunction = GL_ALWAYS;
+ GLuint mStencilReadMask = 0xffffffff;
+ GLuint mStencilReference = 0;
};
}
diff --git a/src/backend/opengl/PipelineGL.cpp b/src/backend/opengl/PipelineGL.cpp
index 9623f8a..26e06a6 100644
--- a/src/backend/opengl/PipelineGL.cpp
+++ b/src/backend/opengl/PipelineGL.cpp
@@ -87,26 +87,26 @@
}
};
- program = glCreateProgram();
+ mProgram = glCreateProgram();
for (auto stage : IterateStages(parent->GetStageMask())) {
const ShaderModule* module = ToBackend(builder->GetStageInfo(stage).module.Get());
GLuint shader = CreateShader(GLShaderType(stage), module->GetSource());
- glAttachShader(program, shader);
+ glAttachShader(mProgram, shader);
}
- glLinkProgram(program);
+ glLinkProgram(mProgram);
GLint linkStatus = GL_FALSE;
- glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
+ glGetProgramiv(mProgram, GL_LINK_STATUS, &linkStatus);
if (linkStatus == GL_FALSE) {
GLint infoLogLength = 0;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
+ glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 1) {
std::vector<char> buffer(infoLogLength);
- glGetProgramInfoLog(program, infoLogLength, nullptr, &buffer[0]);
+ glGetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]);
std::cout << "Program link failed:\n";
std::cout << buffer.data() << std::endl;
}
@@ -114,10 +114,10 @@
for (auto stage : IterateStages(parent->GetStageMask())) {
const ShaderModule* module = ToBackend(builder->GetStageInfo(stage).module.Get());
- FillPushConstants(module, &glPushConstants[stage], program);
+ FillPushConstants(module, &mGlPushConstants[stage], mProgram);
}
- glUseProgram(program);
+ glUseProgram(mProgram);
// The uniforms are part of the program state so we can pre-bind buffer units, texture units etc.
const auto& layout = ToBackend(parent->GetLayout());
@@ -135,15 +135,15 @@
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
{
- GLint location = glGetUniformBlockIndex(program, name.c_str());
- glUniformBlockBinding(program, location, indices[group][binding]);
+ GLint location = glGetUniformBlockIndex(mProgram, name.c_str());
+ glUniformBlockBinding(mProgram, location, indices[group][binding]);
}
break;
case nxt::BindingType::StorageBuffer:
{
- GLuint location = glGetProgramResourceIndex(program, GL_SHADER_STORAGE_BLOCK, name.c_str());
- glShaderStorageBlockBinding(program, location, indices[group][binding]);
+ GLuint location = glGetProgramResourceIndex(mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
+ glShaderStorageBlockBinding(mProgram, location, indices[group][binding]);
}
break;
@@ -167,20 +167,20 @@
}
}
- unitsForSamplers.resize(layout->GetNumSamplers());
- unitsForTextures.resize(layout->GetNumSampledTextures());
+ mUnitsForSamplers.resize(layout->GetNumSamplers());
+ mUnitsForTextures.resize(layout->GetNumSampledTextures());
GLuint textureUnit = layout->GetTextureUnitsUsed();
for (const auto& combined : combinedSamplersSet) {
std::string name = combined.GetName();
- GLint location = glGetUniformLocation(program, name.c_str());
+ GLint location = glGetUniformLocation(mProgram, name.c_str());
glUniform1i(location, textureUnit);
GLuint samplerIndex = indices[combined.samplerLocation.group][combined.samplerLocation.binding];
- unitsForSamplers[samplerIndex].push_back(textureUnit);
+ mUnitsForSamplers[samplerIndex].push_back(textureUnit);
GLuint textureIndex = indices[combined.textureLocation.group][combined.textureLocation.binding];
- unitsForTextures[textureIndex].push_back(textureUnit);
+ mUnitsForTextures[textureIndex].push_back(textureUnit);
textureUnit ++;
}
@@ -188,25 +188,25 @@
}
const PipelineGL::GLPushConstantInfo& PipelineGL::GetGLPushConstants(nxt::ShaderStage stage) const {
- return glPushConstants[stage];
+ return mGlPushConstants[stage];
}
const std::vector<GLuint>& PipelineGL::GetTextureUnitsForSampler(GLuint index) const {
- ASSERT(index < unitsForSamplers.size());
- return unitsForSamplers[index];
+ ASSERT(index < mUnitsForSamplers.size());
+ return mUnitsForSamplers[index];
}
const std::vector<GLuint>& PipelineGL::GetTextureUnitsForTexture(GLuint index) const {
- ASSERT(index < unitsForSamplers.size());
- return unitsForTextures[index];
+ ASSERT(index < mUnitsForSamplers.size());
+ return mUnitsForTextures[index];
}
GLuint PipelineGL::GetProgramHandle() const {
- return program;
+ return mProgram;
}
void PipelineGL::ApplyNow() {
- glUseProgram(program);
+ glUseProgram(mProgram);
}
}
diff --git a/src/backend/opengl/PipelineGL.h b/src/backend/opengl/PipelineGL.h
index f6fe63c..1f1d09b 100644
--- a/src/backend/opengl/PipelineGL.h
+++ b/src/backend/opengl/PipelineGL.h
@@ -43,10 +43,10 @@
void ApplyNow();
private:
- GLuint program;
- PerStage<GLPushConstantInfo> glPushConstants;
- std::vector<std::vector<GLuint>> unitsForSamplers;
- std::vector<std::vector<GLuint>> unitsForTextures;
+ GLuint mProgram;
+ PerStage<GLPushConstantInfo> mGlPushConstants;
+ std::vector<std::vector<GLuint>> mUnitsForSamplers;
+ std::vector<std::vector<GLuint>> mUnitsForTextures;
};
}
diff --git a/src/backend/opengl/PipelineLayoutGL.cpp b/src/backend/opengl/PipelineLayoutGL.cpp
index cff8413..7a2acd1 100644
--- a/src/backend/opengl/PipelineLayoutGL.cpp
+++ b/src/backend/opengl/PipelineLayoutGL.cpp
@@ -36,32 +36,32 @@
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
- indexInfo[group][binding] = uboIndex;
+ mIndexInfo[group][binding] = uboIndex;
uboIndex ++;
break;
case nxt::BindingType::Sampler:
- indexInfo[group][binding] = samplerIndex;
+ mIndexInfo[group][binding] = samplerIndex;
samplerIndex ++;
break;
case nxt::BindingType::SampledTexture:
- indexInfo[group][binding] = sampledTextureIndex;
+ mIndexInfo[group][binding] = sampledTextureIndex;
sampledTextureIndex ++;
break;
case nxt::BindingType::StorageBuffer:
- indexInfo[group][binding] = ssboIndex;
+ mIndexInfo[group][binding] = ssboIndex;
ssboIndex ++;
break;
}
}
}
- numSamplers = samplerIndex;
- numSampledTextures = sampledTextureIndex;
+ mNumSamplers = samplerIndex;
+ mNumSampledTextures = sampledTextureIndex;
}
const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo() const {
- return indexInfo;
+ return mIndexInfo;
}
GLuint PipelineLayout::GetTextureUnitsUsed() const {
@@ -69,11 +69,11 @@
}
size_t PipelineLayout::GetNumSamplers() const {
- return numSamplers;
+ return mNumSamplers;
}
size_t PipelineLayout::GetNumSampledTextures() const {
- return numSampledTextures;
+ return mNumSampledTextures;
}
}
diff --git a/src/backend/opengl/PipelineLayoutGL.h b/src/backend/opengl/PipelineLayoutGL.h
index 3ebfe0e8..2fdea35 100644
--- a/src/backend/opengl/PipelineLayoutGL.h
+++ b/src/backend/opengl/PipelineLayoutGL.h
@@ -36,9 +36,9 @@
size_t GetNumSampledTextures() const;
private:
- BindingIndexInfo indexInfo;
- size_t numSamplers;
- size_t numSampledTextures;
+ BindingIndexInfo mIndexInfo;
+ size_t mNumSamplers;
+ size_t mNumSampledTextures;
};
}
diff --git a/src/backend/opengl/RenderPipelineGL.cpp b/src/backend/opengl/RenderPipelineGL.cpp
index a36a0a5..7684f76 100644
--- a/src/backend/opengl/RenderPipelineGL.cpp
+++ b/src/backend/opengl/RenderPipelineGL.cpp
@@ -44,11 +44,11 @@
RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
: RenderPipelineBase(builder), PipelineGL(this, builder),
- glPrimitiveTopology(GLPrimitiveTopology(GetPrimitiveTopology())) {
+ mGlPrimitiveTopology(GLPrimitiveTopology(GetPrimitiveTopology())) {
}
GLenum RenderPipeline::GetGLPrimitiveTopology() const {
- return glPrimitiveTopology;
+ return mGlPrimitiveTopology;
}
void RenderPipeline::ApplyNow(PersistentPipelineState &persistentPipelineState) {
diff --git a/src/backend/opengl/RenderPipelineGL.h b/src/backend/opengl/RenderPipelineGL.h
index e16ce25..a45f06d 100644
--- a/src/backend/opengl/RenderPipelineGL.h
+++ b/src/backend/opengl/RenderPipelineGL.h
@@ -37,7 +37,7 @@
void ApplyNow(PersistentPipelineState &persistentPipelineState);
private:
- GLenum glPrimitiveTopology;
+ GLenum mGlPrimitiveTopology;
};
}
diff --git a/src/backend/opengl/SamplerGL.cpp b/src/backend/opengl/SamplerGL.cpp
index 742603f..b06c12f 100644
--- a/src/backend/opengl/SamplerGL.cpp
+++ b/src/backend/opengl/SamplerGL.cpp
@@ -59,13 +59,13 @@
Sampler::Sampler(SamplerBuilder* builder)
: SamplerBase(builder) {
- glGenSamplers(1, &handle);
- glSamplerParameteri(handle, GL_TEXTURE_MAG_FILTER, MagFilterMode(builder->GetMagFilter()));
- glSamplerParameteri(handle, GL_TEXTURE_MIN_FILTER, MinFilterMode(builder->GetMinFilter(), builder->GetMipMapFilter()));
+ glGenSamplers(1, &mHandle);
+ glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(builder->GetMagFilter()));
+ glSamplerParameteri(mHandle, GL_TEXTURE_MIN_FILTER, MinFilterMode(builder->GetMinFilter(), builder->GetMipMapFilter()));
}
GLuint Sampler::GetHandle() const {
- return handle;
+ return mHandle;
}
}
diff --git a/src/backend/opengl/SamplerGL.h b/src/backend/opengl/SamplerGL.h
index 86c729d..1c56381 100644
--- a/src/backend/opengl/SamplerGL.h
+++ b/src/backend/opengl/SamplerGL.h
@@ -31,7 +31,7 @@
GLuint GetHandle() const;
private:
- GLuint handle;
+ GLuint mHandle;
};
}
diff --git a/src/backend/opengl/ShaderModuleGL.cpp b/src/backend/opengl/ShaderModuleGL.cpp
index e998ee5..654ac0c 100644
--- a/src/backend/opengl/ShaderModuleGL.cpp
+++ b/src/backend/opengl/ShaderModuleGL.cpp
@@ -92,9 +92,9 @@
compiler.build_combined_image_samplers();
for (const auto& combined : compiler.get_combined_image_samplers()) {
- combinedInfo.emplace_back();
+ mCombinedInfo.emplace_back();
- auto& info = combinedInfo.back();
+ auto& info = mCombinedInfo.back();
info.samplerLocation.group = compiler.get_decoration(combined.sampler_id, spv::DecorationDescriptorSet);
info.samplerLocation.binding = compiler.get_decoration(combined.sampler_id, spv::DecorationBinding);
info.textureLocation.group = compiler.get_decoration(combined.image_id, spv::DecorationDescriptorSet);
@@ -116,15 +116,15 @@
}
}
- glslSource = compiler.compile();
+ mGlslSource = compiler.compile();
}
const char* ShaderModule::GetSource() const {
- return reinterpret_cast<const char*>(glslSource.data());
+ return reinterpret_cast<const char*>(mGlslSource.data());
}
const ShaderModule::CombinedSamplerInfo& ShaderModule::GetCombinedSamplerInfo() const {
- return combinedInfo;
+ return mCombinedInfo;
}
}
diff --git a/src/backend/opengl/ShaderModuleGL.h b/src/backend/opengl/ShaderModuleGL.h
index 8d8f0d6..ccb2deb 100644
--- a/src/backend/opengl/ShaderModuleGL.h
+++ b/src/backend/opengl/ShaderModuleGL.h
@@ -49,8 +49,8 @@
const CombinedSamplerInfo& GetCombinedSamplerInfo() const;
private:
- CombinedSamplerInfo combinedInfo;
- std::string glslSource;
+ CombinedSamplerInfo mCombinedInfo;
+ std::string mGlslSource;
};
}
diff --git a/src/backend/opengl/TextureGL.cpp b/src/backend/opengl/TextureGL.cpp
index 74addc4..d50efe2 100644
--- a/src/backend/opengl/TextureGL.cpp
+++ b/src/backend/opengl/TextureGL.cpp
@@ -64,8 +64,8 @@
}
Texture::Texture(TextureBuilder* builder, GLuint handle)
- : TextureBase(builder), handle(handle) {
- target = TargetForDimension(GetDimension());
+ : TextureBase(builder), mHandle(handle) {
+ mTarget = TargetForDimension(GetDimension());
uint32_t width = GetWidth();
uint32_t height = GetHeight();
@@ -73,17 +73,17 @@
auto formatInfo = GetGLFormatInfo(GetFormat());
- glBindTexture(target, handle);
+ glBindTexture(mTarget, handle);
for (uint32_t i = 0; i < levels; ++i) {
- glTexImage2D(target, i, formatInfo.internalFormat, width, height, 0, formatInfo.format, formatInfo.type, nullptr);
+ glTexImage2D(mTarget, i, formatInfo.internalFormat, width, height, 0, formatInfo.format, formatInfo.type, nullptr);
width = std::max(uint32_t(1), width / 2);
height = std::max(uint32_t(1), height / 2);
}
// The texture is not complete if it uses mipmapping and not all levels up to
// MAX_LEVEL have been defined.
- glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels - 1);
+ glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, levels - 1);
}
Texture::~Texture() {
@@ -91,11 +91,11 @@
}
GLuint Texture::GetHandle() const {
- return handle;
+ return mHandle;
}
GLenum Texture::GetGLTarget() const {
- return target;
+ return mTarget;
}
TextureFormatInfo Texture::GetGLFormat() const {
diff --git a/src/backend/opengl/TextureGL.h b/src/backend/opengl/TextureGL.h
index c53dc76..648c5a1 100644
--- a/src/backend/opengl/TextureGL.h
+++ b/src/backend/opengl/TextureGL.h
@@ -43,8 +43,8 @@
void TransitionUsageImpl(nxt::TextureUsageBit currentUsage, nxt::TextureUsageBit targetUsage) override;
private:
- GLuint handle;
- GLenum target;
+ GLuint mHandle;
+ GLenum mTarget;
};
class TextureView : public TextureViewBase {