This commit fixes several issues in this test:
- Coordinate X conversion from float in [0, 1] range to uint in range
[0, m_to_with] is wrong. Same for coordinate Y.
- Offset drawing point for primitive point is wrong.
- Generated vertex shader for the case of dynamic index writes with
culling but not clipping fails to compile, due "unsized array index must
be constant". This happens because we make reference in the code to the
clipdistance array, which is unsized. This problem also happens with
clipping but not culling.
- Program fails to link when using tessellation shaders, due
"definitions of interface block `gl_PerVertex' do not match". This
happens because tessellation control shader redefines gl_PerVertex, but
tessellation evaluation shader don't.
Components: OpenGL
VK-GL-CTS issue: 191
Affects:
GL45-CTS.cull_distance.functional
Change-Id: I5143b45caa5a0490f58628326b44c4373d5c8305
culldistances_array_size > 0 ? culldistances_array_size : 1; /* Avoid zero-sized array compilation error */
static const glw::GLchar* dynamic_array_setters =
"\n"
culldistances_array_size > 0 ? culldistances_array_size : 1; /* Avoid zero-sized array compilation error */
static const glw::GLchar* dynamic_array_setters =
"\n"
- " for (int n_clipdistance_entry = 0;\n"
- " n_clipdistance_entry < TEMPLATE_N_GL_CLIPDISTANCE_ENTRIES;\n"
- " ++n_clipdistance_entry)\n"
- " {\n"
- " ASSIGN_CLIP_DISTANCE(n_clipdistance_entry);\n"
- " }\n"
+ "#if TEMPLATE_N_GL_CLIPDISTANCE_ENTRIES\n"
+ " for (int n_clipdistance_entry = 0;\n"
+ " n_clipdistance_entry < TEMPLATE_N_GL_CLIPDISTANCE_ENTRIES;\n"
+ " ++n_clipdistance_entry)\n"
+ " {\n"
+ " ASSIGN_CLIP_DISTANCE(n_clipdistance_entry);\n"
+ " }\n"
+ "#endif"
- " for (int n_culldistance_entry = 0;\n"
- " n_culldistance_entry < TEMPLATE_N_GL_CULLDISTANCE_ENTRIES;\n"
- " ++n_culldistance_entry)\n"
- " {\n"
- " ASSIGN_CULL_DISTANCE(n_culldistance_entry);\n"
- " }\n";
+ "#if TEMPLATE_N_GL_CULLDISTANCE_ENTRIES \n"
+ " for (int n_culldistance_entry = 0;\n"
+ " n_culldistance_entry < TEMPLATE_N_GL_CULLDISTANCE_ENTRIES;\n"
+ " ++n_culldistance_entry)\n"
+ " {\n"
+ " ASSIGN_CULL_DISTANCE(n_culldistance_entry);\n"
+ " }\n"
+ "#endif\n";
static const glw::GLchar* core_functionality = "#version 450\n";
static const glw::GLchar* core_functionality = "#version 450\n";
"\n"
"TEMPLATE_LAYOUT_IN\n"
"\n"
"\n"
"TEMPLATE_LAYOUT_IN\n"
"\n"
+ "in gl_PerVertex {\n"
+ "TEMPLATE_REDECLARE_IN_CLIPDISTANCE\n"
+ "TEMPLATE_REDECLARE_IN_CULLDISTANCE\n"
+ "vec4 gl_Position;\n"
+ "} gl_in[];\n"
+ "\n"
"TEMPLATE_REDECLARE_CLIPDISTANCE\n"
"TEMPLATE_REDECLARE_CULLDISTANCE\n"
"TEMPLATE_REDECLARE_CLIPDISTANCE\n"
"TEMPLATE_REDECLARE_CULLDISTANCE\n"
"#define ASSIGN_CLIP_DISTANCE(IDX) TEMPLATE_ASSIGN_CLIP_DISTANCE\n"
"#define ASSIGN_CULL_DISTANCE(IDX) TEMPLATE_ASSIGN_CULL_DISTANCE\n"
"\n"
"#define ASSIGN_CLIP_DISTANCE(IDX) TEMPLATE_ASSIGN_CLIP_DISTANCE\n"
"#define ASSIGN_CULL_DISTANCE(IDX) TEMPLATE_ASSIGN_CULL_DISTANCE\n"
"\n"
std::string array_setters;
std::string clipdistance_array_declaration;
std::string culldistance_array_declaration;
std::string array_setters;
std::string clipdistance_array_declaration;
std::string culldistance_array_declaration;
+ std::string clipdistance_in_array_declaration;
+ std::string culldistance_in_array_declaration;
std::string& shader_source = shaders_configuration[n_shader_index].body;
/* Copy template into shader body source */
std::string& shader_source = shaders_configuration[n_shader_index].body;
/* Copy template into shader body source */
clipdistance_array_declaration = std::string("out float gl_ClipDistance[") +
CullDistance::Utilities::intToString(clipdistances_array_size) +
std::string("];");
clipdistance_array_declaration = std::string("out float gl_ClipDistance[") +
CullDistance::Utilities::intToString(clipdistances_array_size) +
std::string("];");
+ clipdistance_in_array_declaration = std::string("in float gl_ClipDistance[") +
+ CullDistance::Utilities::intToString(clipdistances_array_size) +
+ std::string("];");
}
}
CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_CLIPDISTANCE"),
clipdistance_array_declaration);
}
}
CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_CLIPDISTANCE"),
clipdistance_array_declaration);
+ CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_IN_CLIPDISTANCE"),
+ clipdistance_in_array_declaration);
/* Adjust culldistances declaration */
if (redeclare_culldistances && culldistances_array_size > 0)
/* Adjust culldistances declaration */
if (redeclare_culldistances && culldistances_array_size > 0)
culldistance_array_declaration = std::string("out float gl_CullDistance[") +
CullDistance::Utilities::intToString(culldistances_array_size) +
std::string("];");
culldistance_array_declaration = std::string("out float gl_CullDistance[") +
CullDistance::Utilities::intToString(culldistances_array_size) +
std::string("];");
+ culldistance_in_array_declaration = std::string("in float gl_CullDistance[") +
+ CullDistance::Utilities::intToString(culldistances_array_size) +
+ std::string("];");
}
}
CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_CULLDISTANCE"),
culldistance_array_declaration);
}
}
CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_CULLDISTANCE"),
culldistance_array_declaration);
+ CullDistance::Utilities::replaceAll(shader_source, std::string("TEMPLATE_REDECLARE_IN_CULLDISTANCE"),
+ culldistance_in_array_declaration);
/* Adjust clip/cull distances setters */
if (dynamic_index_writes)
/* Adjust clip/cull distances setters */
if (dynamic_index_writes)
1, sub_grid_cell_size - 2
}; /* pixel y offsets to subgrid cell origin for line primitive */
const glw::GLuint offsets_point_draw_x[1] = {
1, sub_grid_cell_size - 2
}; /* pixel y offsets to subgrid cell origin for line primitive */
const glw::GLuint offsets_point_draw_x[1] = {
}; /* vertex x offsets to subgrid cell origin for point primitive */
const glw::GLuint offsets_point_draw_y[1] = {
2
}; /* vertex x offsets to subgrid cell origin for point primitive */
const glw::GLuint offsets_point_draw_y[1] = {
2
glw::GLuint base_index_of_vertex = base_index_of_primitive;
glw::GLuint checkpoint_position_index = base_index_of_vertex + clipdistances_array_size +
culldistances_array_size + 2 /* ignore vertex coordinates */;
glw::GLuint base_index_of_vertex = base_index_of_primitive;
glw::GLuint checkpoint_position_index = base_index_of_vertex + clipdistances_array_size +
culldistances_array_size + 2 /* ignore vertex coordinates */;
- glw::GLint checkpoint_x = glw::GLint(m_to_width * glw::GLint(m_bo_data[checkpoint_position_index]));
- glw::GLint checkpoint_y = glw::GLint(m_to_height * glw::GLint(m_bo_data[checkpoint_position_index + 1]));
+ glw::GLint checkpoint_x = glw::GLint(glw::GLfloat(m_to_width) * m_bo_data[checkpoint_position_index]);
+ glw::GLint checkpoint_y = glw::GLint(glw::GLfloat(m_to_height) * m_bo_data[checkpoint_position_index + 1]);
glw::GLint origin_x = checkpoint_x - 1;
glw::GLint origin_y = checkpoint_y - 1;
glw::GLint origin_x = checkpoint_x - 1;
glw::GLint origin_y = checkpoint_y - 1;
for (glw::GLint pixel_offset = 0; pixel_offset < m_sub_grid_cell_size; pixel_offset++)
{
if (readRedPixelValue(origin_x + pixel_offset, origin_y) != 0)
for (glw::GLint pixel_offset = 0; pixel_offset < m_sub_grid_cell_size; pixel_offset++)
{
if (readRedPixelValue(origin_x + pixel_offset, origin_y) != 0)
clipdistances_array_size + culldistances_array_size +
2 /* ignore vertex coordinates */;
glw::GLint checkpoint_x_internal =
clipdistances_array_size + culldistances_array_size +
2 /* ignore vertex coordinates */;
glw::GLint checkpoint_x_internal =
- glw::GLint(m_to_width * glw::GLint(m_bo_data[checkpoint_position_index_internal]));
+ glw::GLint(glw::GLfloat(m_to_width) * m_bo_data[checkpoint_position_index_internal]);
glw::GLint checkpoint_y_internal =
glw::GLint checkpoint_y_internal =
- glw::GLint(m_to_height * glw::GLint(m_bo_data[checkpoint_position_index_internal + 1]));
+ glw::GLint(glw::GLfloat(m_to_height) * m_bo_data[checkpoint_position_index_internal + 1]);
glw::GLint vertex_color_red_value = readRedPixelValue(checkpoint_x_internal, checkpoint_y_internal);
/* Make sure vertex is invisible */
glw::GLint vertex_color_red_value = readRedPixelValue(checkpoint_x_internal, checkpoint_y_internal);
/* Make sure vertex is invisible */
glw::GLuint checkpoint_position_index_internal = base_index_of_vertex_internal + clipdistances_array_size +
culldistances_array_size +
2 /* ignore vertex coordinates */;
glw::GLuint checkpoint_position_index_internal = base_index_of_vertex_internal + clipdistances_array_size +
culldistances_array_size +
2 /* ignore vertex coordinates */;
- glw::GLuint checkpoint_x_internal =
- glw::GLint(m_to_width * glw::GLint(m_bo_data[checkpoint_position_index_internal]));
- glw::GLuint checkpoint_y_internal =
- glw::GLint(m_to_height * glw::GLint(m_bo_data[checkpoint_position_index_internal + 1]));
+ glw::GLint checkpoint_x_internal =
+ glw::GLint(glw::GLfloat(m_to_width) * m_bo_data[checkpoint_position_index_internal]);
+ glw::GLint checkpoint_y_internal =
+ glw::GLint(glw::GLfloat(m_to_height) * m_bo_data[checkpoint_position_index_internal + 1]);
glw::GLfloat* vertex_clipdistance_array = &m_bo_data[clipdistance_array_index];
bool vertex_clipped = false;
glw::GLint vertex_clipped_by_distance = 0;
glw::GLfloat* vertex_clipdistance_array = &m_bo_data[clipdistance_array_index];
bool vertex_clipped = false;
glw::GLint vertex_clipped_by_distance = 0;
base_index_of_vertex_internal + clipdistances_array_size + culldistances_array_size +
2 /* ignore vertex coordinates */;
glw::GLuint culldistances_index = base_index_of_vertex_internal + clipdistances_array_size;
base_index_of_vertex_internal + clipdistances_array_size + culldistances_array_size +
2 /* ignore vertex coordinates */;
glw::GLuint culldistances_index = base_index_of_vertex_internal + clipdistances_array_size;
- glw::GLuint checkpoint_x_internal =
- glw::GLint(m_to_width * glw::GLint(m_bo_data[checkpoint_position_index_internal]));
- glw::GLuint checkpoint_y_internal =
- glw::GLint(m_to_height * glw::GLint(m_bo_data[checkpoint_position_index_internal + 1]));
+ glw::GLint checkpoint_x_internal =
+ glw::GLint(glw::GLfloat(m_to_width) * m_bo_data[checkpoint_position_index_internal]);
+ glw::GLint checkpoint_y_internal =
+ glw::GLint(glw::GLfloat(m_to_height) * m_bo_data[checkpoint_position_index_internal + 1]);
glw::GLint vertex_color_red_value = readRedPixelValue(checkpoint_x_internal, checkpoint_y_internal);
/* Calculate culldistances check sum hash */
glw::GLint vertex_color_red_value = readRedPixelValue(checkpoint_x_internal, checkpoint_y_internal);
/* Calculate culldistances check sum hash */