Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniform buffer info #218

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/voglcommon/vogl_program_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,23 @@ bool vogl_program_state::snapshot_uniform_blocks(const vogl_context_info &contex
GL_ENTRYPOINT(glGetActiveUniformBlockiv)(m_snapshot_handle, uniform_block_index, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &state.m_uniform_block_active_uniforms);
VOGL_CHECK_GL_ERROR;

// TODO: Get and store referenced flags: GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, or GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, etc.
#define GET_REFERENCED_BY(name, flag_name) do { \
GLint referenced; \
GL_ENTRYPOINT(glGetActiveUniformBlockiv)(m_snapshot_handle, uniform_block_index, GL_UNIFORM_BLOCK_REFERENCED_BY_ ## name ## _SHADER, &referenced); \
VOGL_CHECK_GL_ERROR; \
if (referenced) \
state.m_referenced_by |= cBufferReferencedBy ## flag_name; \
} while (0)

GET_REFERENCED_BY(VERTEX, Vertex);
GET_REFERENCED_BY(TESS_CONTROL, TesselationControl);
GET_REFERENCED_BY(TESS_EVALUATION, TesselationEvaluation);
GET_REFERENCED_BY(GEOMETRY, Geometry);
GET_REFERENCED_BY(FRAGMENT, Fragment);
if (context_info.get_version() >= VOGL_GL_VERSION_4_3)
GET_REFERENCED_BY(COMPUTE, Compute);

#undef GET_REFERENCED_BY

m_uniform_blocks.push_back(state);
}
Expand Down
12 changes: 12 additions & 0 deletions src/voglcommon/vogl_program_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ struct vogl_program_uniform_state

typedef vogl::vector<vogl_program_uniform_state> vogl_uniform_state_vec;

enum vogl_referenced_by_flags {
cBufferReferencedByVertex = 1,
cBufferReferencedByTesselationControl = 2,
cBufferReferencedByTesselationEvaluation = 4,
cBufferReferencedByGeometry = 8,
cBufferReferencedByFragment = 16,
cBufferReferencedByCompute = 32,
};

struct vogl_program_uniform_block_state
{
GLuint m_uniform_block_index;
dynamic_string m_name;
GLint m_uniform_block_binding_point;
GLint m_uniform_block_data_size;
GLint m_uniform_block_active_uniforms;
int m_referenced_by;

void clear()
{
Expand All @@ -100,6 +110,7 @@ struct vogl_program_uniform_block_state
m_uniform_block_binding_point = 0;
m_uniform_block_data_size = 0;
m_uniform_block_active_uniforms = 0;
m_referenced_by = 0;
}

inline bool operator==(const vogl_program_uniform_block_state &rhs) const
Expand All @@ -112,6 +123,7 @@ struct vogl_program_uniform_block_state
CMP(m_uniform_block_binding_point)
CMP(m_uniform_block_data_size)
CMP(m_uniform_block_active_uniforms)
CMP(m_referenced_by)
#undef CMP
return true;
}
Expand Down
31 changes: 31 additions & 0 deletions src/vogleditor/vogleditor_qprogramexplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,37 @@ void vogleditor_QProgramExplorer::update_uniforms_for_program(vogl_program_state
} // end uniform element index
}

const vogl_uniform_block_state_vec &uniformBlockVec = pProgramState->get_uniform_block_state_vec();
for (uint i = 0; i < uniformBlockVec.size(); i++)
{
QString varName = QString("%1").arg(uniformBlockVec[i].m_name.c_str());

ui->uniformTableWidget->insertRow(rowIndex);

QStringList references;
int referenced_by = uniformBlockVec[i].m_referenced_by;

if (referenced_by & cBufferReferencedByVertex)
references.append("vertex");
if (referenced_by & cBufferReferencedByTesselationControl)
references.append("tesselation control");
if (referenced_by & cBufferReferencedByTesselationEvaluation)
references.append("tesselation evaluation");
if (referenced_by & cBufferReferencedByGeometry)
references.append("geometry");
if (referenced_by & cBufferReferencedByFragment)
references.append("fragment");
if (referenced_by & cBufferReferencedByCompute)
references.append("compute");

ui->uniformTableWidget->setItem(rowIndex, vogleditor_utc_location, new QTableWidgetItem(QString("%1").arg(i)));
ui->uniformTableWidget->setItem(rowIndex, vogleditor_utc_name, new QTableWidgetItem(varName));
ui->uniformTableWidget->setItem(rowIndex, vogleditor_utc_value, new QTableWidgetItem(references.join(", ")));
ui->uniformTableWidget->setItem(rowIndex, vogleditor_utc_type, new QTableWidgetItem(QString("%1 bytes").arg(uniformBlockVec[i].m_uniform_block_data_size)));

rowIndex++;
}

// resize columns so that they are properly sized, but still allow the user to resize them more if needed
ui->uniformTableWidget->horizontalHeader()->setSectionResizeMode(vogleditor_utc_location, QHeaderView::ResizeToContents);
uint tmpWidth = ui->uniformTableWidget->horizontalHeader()->sectionSize(vogleditor_utc_location);
Expand Down