Skip to content

Commit

Permalink
glstate: Dump images (glBindImage) to displayed surfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
schulmar authored and jrfonseca committed Nov 4, 2015
1 parent b2c7610 commit 34b56c7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions retrace/glstate.cpp
Expand Up @@ -59,6 +59,8 @@ Context::Context(void) {
ARB_get_program_binary = ext.has("GL_ARB_get_program_binary");
KHR_debug = !ES && ext.has("GL_KHR_debug");
EXT_debug_label = ext.has("GL_EXT_debug_label");
ARB_direct_state_access = ext.has("GL_ARB_direct_state_access");
ARB_shader_image_load_store = ext.has("GL_ARB_shader_image_load_store");

NV_read_depth_stencil = ES && ext.has("GL_NV_read_depth_stencil");
}
Expand Down
49 changes: 49 additions & 0 deletions retrace/glstate_images.cpp
Expand Up @@ -608,6 +608,53 @@ dumpActiveTexture(StateWriter &writer, Context &context, GLenum target, GLuint t
}


static void
dumpTextureImages(StateWriter &writer, Context &context)
{
if(!(context.ARB_shader_image_load_store &&
context.ARB_direct_state_access)) {
return;
}

GLint maxImageUnits = 0;
glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImageUnits);
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);

for(GLint imageUnit = 0; imageUnit < maxImageUnits; ++imageUnit) {
GLint texture = 0;
glGetIntegeri_v(GL_IMAGE_BINDING_NAME, imageUnit, &texture);
if(texture) {
GLint level = 0;
glGetIntegeri_v(GL_IMAGE_BINDING_LEVEL, imageUnit, &level);
GLint isLayered = 0;
glGetIntegeri_v(GL_IMAGE_BINDING_LAYERED, imageUnit, &isLayered);
GLint layer = 0;
glGetIntegeri_v(GL_IMAGE_BINDING_LAYER, imageUnit, &layer);
std::stringstream label;
label << "Image Unit " << imageUnit;
if (level) {
label << ", level = " << level;
}
if (isLayered) {
label << ", layer = " << layer;
}
GLint target = 0;
// relies on GL_ARB_direct_state_access
glGetTextureParameteriv(texture, GL_TEXTURE_TARGET, &target);
GLint previousTexture = 0;
glGetIntegerv(getTextureBinding(target), &previousTexture);

glBindTexture(target, texture);
char *object_label = getObjectLabel(context, GL_TEXTURE, texture);
dumpActiveTextureLevel(writer, context, target, level, label.str(),
object_label);
free(object_label);
glBindTexture(target, previousTexture);
}
}
}


void
dumpTextures(StateWriter &writer, Context &context)
{
Expand Down Expand Up @@ -667,6 +714,8 @@ dumpTextures(StateWriter &writer, Context &context)

glActiveTexture(active_texture);

dumpTextureImages(writer, context);

writer.endObject();
writer.endMember(); // textures
}
Expand Down
2 changes: 2 additions & 0 deletions retrace/glstate_internal.hpp
Expand Up @@ -50,6 +50,8 @@ struct Context
unsigned KHR_debug:1;
unsigned EXT_debug_label:1;
unsigned NV_read_depth_stencil:1; /* ES only */
unsigned ARB_shader_image_load_store:1;
unsigned ARB_direct_state_access:1;

Context(void);
};
Expand Down

0 comments on commit 34b56c7

Please sign in to comment.