#include "glheader.h"
#include "context.h"
#include "blend.h"
+#include "debug_output.h"
#include "enable.h"
#include "enums.h"
#include "errors.h"
EXTRA_VALID_CLIP_DISTANCE,
EXTRA_FLUSH_CURRENT,
EXTRA_GLSL_130,
- EXTRA_EXT_UBO_GS4,
- EXTRA_EXT_ATOMICS_GS4,
- EXTRA_EXT_SHADER_IMAGE_GS4,
+ EXTRA_EXT_UBO_GS,
+ EXTRA_EXT_ATOMICS_GS,
+ EXTRA_EXT_SHADER_IMAGE_GS,
EXTRA_EXT_ATOMICS_TESS,
EXTRA_EXT_SHADER_IMAGE_TESS,
+ EXTRA_EXT_SSBO_GS,
+ EXTRA_EXT_FB_NO_ATTACH_GS,
+ EXTRA_EXT_ES_GS,
};
#define NO_EXTRA NULL
};
static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
- EXTRA_EXT_UBO_GS4,
+ EXTRA_EXT_UBO_GS,
EXTRA_END
};
};
static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
- EXTRA_EXT_ATOMICS_GS4,
+ EXTRA_EXT_ATOMICS_GS,
EXTRA_END
};
static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
- EXTRA_EXT_SHADER_IMAGE_GS4,
+ EXTRA_EXT_SHADER_IMAGE_GS,
EXTRA_END
};
EXTRA_END
};
+static const int extra_ARB_shader_storage_buffer_object_es31[] = {
+ EXT(ARB_shader_storage_buffer_object),
+ EXTRA_API_ES31,
+ EXTRA_END
+};
+
+static const int extra_ARB_shader_storage_buffer_object_and_geometry_shader[] = {
+ EXTRA_EXT_SSBO_GS,
+ EXTRA_END
+};
+
+static const int extra_ARB_shader_image_load_store_shader_storage_buffer_object_es31[] = {
+ EXT(ARB_shader_image_load_store),
+ EXT(ARB_shader_storage_buffer_object),
+ EXTRA_API_ES31,
+ EXTRA_END
+};
+
+static const int extra_ARB_framebuffer_no_attachments_and_geometry_shader[] = {
+ EXTRA_EXT_FB_NO_ATTACH_GS,
+ EXTRA_END
+};
+
+static const int extra_ARB_viewport_array_or_oes_geometry_shader[] = {
+ EXT(ARB_viewport_array),
+ EXTRA_EXT_ES_GS,
+ EXTRA_END
+};
+
+static const int extra_ARB_gpu_shader5_or_oes_geometry_shader[] = {
+ EXT(ARB_gpu_shader5),
+ EXTRA_EXT_ES_GS,
+ EXTRA_END
+};
+
+static const int extra_ARB_gpu_shader5_or_OES_sample_variables[] = {
+ EXT(ARB_gpu_shader5),
+ EXT(OES_sample_variables),
+};
+
EXTRA_EXT(ARB_texture_cube_map);
EXTRA_EXT(EXT_texture_array);
EXTRA_EXT(NV_fog_distance);
EXTRA_EXT(ARB_vertex_program);
EXTRA_EXT2(NV_point_sprite, ARB_point_sprite);
EXTRA_EXT2(ARB_vertex_program, ARB_fragment_program);
-EXTRA_EXT(ARB_geometry_shader4);
EXTRA_EXT(ARB_color_buffer_float);
EXTRA_EXT(EXT_framebuffer_sRGB);
EXTRA_EXT(OES_EGL_image_external);
EXTRA_EXT(ARB_draw_indirect);
EXTRA_EXT(ARB_shader_image_load_store);
EXTRA_EXT(ARB_viewport_array);
-EXTRA_EXT(ARB_compute_shader);
-EXTRA_EXT(ARB_gpu_shader5);
+EXTRA_EXT(ARB_query_buffer_object);
EXTRA_EXT2(ARB_transform_feedback3, ARB_gpu_shader5);
EXTRA_EXT(INTEL_performance_query);
EXTRA_EXT(ARB_explicit_uniform_location);
EXTRA_EXT(ARB_framebuffer_no_attachments);
EXTRA_EXT(ARB_tessellation_shader);
EXTRA_EXT(ARB_shader_subroutine);
+EXTRA_EXT(ARB_shader_storage_buffer_object);
+EXTRA_EXT(ARB_indirect_parameters);
+EXTRA_EXT(ATI_meminfo);
+EXTRA_EXT(NVX_gpu_memory_info);
+EXTRA_EXT(ARB_cull_distance);
+EXTRA_EXT(EXT_window_rectangles);
static const int
extra_ARB_color_buffer_float_or_glcore[] = {
static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END };
static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END };
static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END };
-static const int extra_version_40[] = { EXTRA_VERSION_40, EXTRA_END };
static const int extra_gl30_es3[] = {
EXTRA_VERSION_30,
EXTRA_END,
};
-static const int extra_gl32_ARB_geometry_shader4[] = {
+static const int extra_version_32_OES_geometry_shader[] = {
EXTRA_VERSION_32,
- EXT(ARB_geometry_shader4),
+ EXTRA_EXT_ES_GS,
EXTRA_END
};
* collisions for any enum (typical numbers). And the code is very
* simple, even though it feels a little magic. */
-#ifdef GET_DEBUG
-static void
-print_table_stats(int api)
-{
- int i, j, collisions[11], count, hash, mask;
- const struct value_desc *d;
- const char *api_names[] = {
- [API_OPENGL_COMPAT] = "GL",
- [API_OPENGL_CORE] = "GL_CORE",
- [API_OPENGLES] = "GLES",
- [API_OPENGLES2] = "GLES2",
- };
- const char *api_name;
-
- api_name = api < ARRAY_SIZE(api_names) ? api_names[api] : "N/A";
- count = 0;
- mask = ARRAY_SIZE(table(api)) - 1;
- memset(collisions, 0, sizeof collisions);
-
- for (i = 0; i < ARRAY_SIZE(table(api)); i++) {
- if (!table(api)[i])
- continue;
- count++;
- d = &values[table(api)[i]];
- hash = (d->pname * prime_factor);
- j = 0;
- while (1) {
- if (values[table(api)[hash & mask]].pname == d->pname)
- break;
- hash += prime_step;
- j++;
- }
-
- if (j < 10)
- collisions[j]++;
- else
- collisions[10]++;
- }
-
- printf("number of enums for %s: %d (total %ld)\n",
- api_name, count, ARRAY_SIZE(values));
- for (i = 0; i < ARRAY_SIZE(collisions) - 1; i++)
- if (collisions[i] > 0)
- printf(" %d enums with %d %scollisions\n",
- collisions[i], i, i == 10 ? "or more " : "");
-}
-#endif
-
-/**
- * Initialize the enum hash for a given API
- *
- * This is called from one_time_init() to insert the enum values that
- * are valid for the API in question into the enum hash table.
- *
- * \param the current context, for determining the API in question
- */
-void _mesa_init_get_hash(struct gl_context *ctx)
-{
-#ifdef GET_DEBUG
- print_table_stats(ctx->API);
-#else
- (void) ctx;
-#endif
-}
-
/**
* Handle irregular enums
*
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
- case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_RECTANGLE_NV:
case GL_TEXTURE_EXTERNAL_OES:
v->value_bool = _mesa_IsEnabled(d->pname);
case GL_SHADER_STORAGE_BUFFER_BINDING:
v->value_int = ctx->ShaderStorageBuffer->Name;
break;
+ /* GL_ARB_query_buffer_object */
+ case GL_QUERY_BUFFER_BINDING:
+ v->value_int = ctx->QueryBuffer->Name;
+ break;
/* GL_ARB_timer_query */
case GL_TIMESTAMP:
if (ctx->Driver.GetTimestamp) {
}
break;
/* GL_KHR_DEBUG */
+ case GL_DEBUG_OUTPUT:
+ case GL_DEBUG_OUTPUT_SYNCHRONOUS:
case GL_DEBUG_LOGGED_MESSAGES:
case GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH:
case GL_DEBUG_GROUP_STACK_DEPTH:
case GL_DRAW_INDIRECT_BUFFER_BINDING:
v->value_int = ctx->DrawIndirectBuffer->Name;
break;
+ /* GL_ARB_indirect_parameters */
+ case GL_PARAMETER_BUFFER_BINDING_ARB:
+ v->value_int = ctx->ParameterBuffer->Name;
+ break;
/* GL_ARB_separate_shader_objects */
case GL_PROGRAM_PIPELINE_BINDING:
if (ctx->Pipeline.Current) {
case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
v->value_int = ctx->DispatchIndirectBuffer->Name;
break;
+ /* GL_ARB_multisample */
+ case GL_SAMPLES:
+ v->value_int = _mesa_geometric_samples(ctx->DrawBuffer);
+ break;
+ case GL_SAMPLE_BUFFERS:
+ v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0;
+ break;
+ /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
+ case GL_VBO_FREE_MEMORY_ATI:
+ case GL_TEXTURE_FREE_MEMORY_ATI:
+ case GL_RENDERBUFFER_FREE_MEMORY_ATI:
+ case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
+ case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
+ case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
+ case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
+ case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
+ {
+ struct gl_memory_info info;
+
+ ctx->Driver.QueryMemoryInfo(ctx, &info);
+
+ if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
+ v->value_int = info.total_device_memory;
+ else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
+ v->value_int = info.total_device_memory +
+ info.total_staging_memory;
+ else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
+ v->value_int = info.avail_device_memory;
+ else if (d->pname == GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX)
+ v->value_int = info.nr_device_memory_evictions;
+ else if (d->pname == GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX)
+ v->value_int = info.device_memory_evicted;
+ else {
+ /* ATI free memory enums.
+ *
+ * Since the GPU memory is (usually) page-table based, every two
+ * consecutive elements are equal. From the GL_ATI_meminfo
+ * specification:
+ *
+ * "param[0] - total memory free in the pool
+ * param[1] - largest available free block in the pool
+ * param[2] - total auxiliary memory free
+ * param[3] - largest auxiliary free block"
+ *
+ * All three (VBO, TEXTURE, RENDERBUFFER) queries return
+ * the same numbers here.
+ */
+ v->value_int_4[0] = info.avail_device_memory;
+ v->value_int_4[1] = info.avail_device_memory;
+ v->value_int_4[2] = info.avail_staging_memory;
+ v->value_int_4[3] = info.avail_staging_memory;
+ }
+ }
+ break;
}
}
if (ctx->Const.GLSLVersion >= 130)
api_found = GL_TRUE;
break;
- case EXTRA_EXT_UBO_GS4:
+ case EXTRA_EXT_UBO_GS:
api_check = GL_TRUE;
- api_found = (ctx->Extensions.ARB_uniform_buffer_object &&
- _mesa_has_geometry_shaders(ctx));
+ if (ctx->Extensions.ARB_uniform_buffer_object &&
+ _mesa_has_geometry_shaders(ctx))
+ api_found = GL_TRUE;
break;
- case EXTRA_EXT_ATOMICS_GS4:
+ case EXTRA_EXT_ATOMICS_GS:
api_check = GL_TRUE;
- api_found = (ctx->Extensions.ARB_shader_atomic_counters &&
- _mesa_has_geometry_shaders(ctx));
+ if (ctx->Extensions.ARB_shader_atomic_counters &&
+ _mesa_has_geometry_shaders(ctx))
+ api_found = GL_TRUE;
break;
- case EXTRA_EXT_SHADER_IMAGE_GS4:
+ case EXTRA_EXT_SHADER_IMAGE_GS:
api_check = GL_TRUE;
- api_found = (ctx->Extensions.ARB_shader_image_load_store &&
- _mesa_has_geometry_shaders(ctx));
+ if (ctx->Extensions.ARB_shader_image_load_store &&
+ _mesa_has_geometry_shaders(ctx))
+ api_found = GL_TRUE;
break;
case EXTRA_EXT_ATOMICS_TESS:
api_check = GL_TRUE;
api_found = ctx->Extensions.ARB_shader_image_load_store &&
_mesa_has_tessellation(ctx);
break;
+ case EXTRA_EXT_SSBO_GS:
+ api_check = GL_TRUE;
+ if (ctx->Extensions.ARB_shader_storage_buffer_object &&
+ _mesa_has_geometry_shaders(ctx))
+ api_found = GL_TRUE;
+ break;
+ case EXTRA_EXT_FB_NO_ATTACH_GS:
+ api_check = GL_TRUE;
+ if (ctx->Extensions.ARB_framebuffer_no_attachments &&
+ (_mesa_is_desktop_gl(ctx) ||
+ _mesa_has_OES_geometry_shader(ctx)))
+ api_found = GL_TRUE;
+ break;
+ case EXTRA_EXT_ES_GS:
+ api_check = GL_TRUE;
+ if (_mesa_has_OES_geometry_shader(ctx))
+ api_found = GL_TRUE;
+ break;
case EXTRA_END:
break;
default: /* *e is a offset into the extension struct */
break;
case TYPE_FLOATN_4:
- params[3] = FLOAT_TO_INT64(((GLfloat *) p)[3]);
+ params[3] = FLOAT_TO_INT(((GLfloat *) p)[3]);
case TYPE_FLOATN_3:
- params[2] = FLOAT_TO_INT64(((GLfloat *) p)[2]);
+ params[2] = FLOAT_TO_INT(((GLfloat *) p)[2]);
case TYPE_FLOATN_2:
- params[1] = FLOAT_TO_INT64(((GLfloat *) p)[1]);
+ params[1] = FLOAT_TO_INT(((GLfloat *) p)[1]);
case TYPE_FLOATN:
- params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]);
+ params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
break;
case TYPE_DOUBLEN_2:
- params[1] = FLOAT_TO_INT64(((GLdouble *) p)[1]);
+ params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
- params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]);
+ params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
break;
case TYPE_INT_4:
|| _mesa_is_gles3(ctx)
? TEXTURE_2D_ARRAY_INDEX : -1;
case GL_TEXTURE_BINDING_BUFFER:
- return ctx->API == API_OPENGL_CORE &&
- ctx->Extensions.ARB_texture_buffer_object ?
+ return (_mesa_has_ARB_texture_buffer_object(ctx) ||
+ _mesa_has_OES_texture_buffer(ctx)) ?
TEXTURE_BUFFER_INDEX : -1;
case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_cube_map_array
v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height;
return TYPE_INT_4;
+ case GL_WINDOW_RECTANGLE_EXT:
+ if (!ctx->Extensions.EXT_window_rectangles)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxWindowRectangles)
+ goto invalid_value;
+ v->value_int_4[0] = ctx->Scissor.WindowRects[index].X;
+ v->value_int_4[1] = ctx->Scissor.WindowRects[index].Y;
+ v->value_int_4[2] = ctx->Scissor.WindowRects[index].Width;
+ v->value_int_4[3] = ctx->Scissor.WindowRects[index].Height;
+ return TYPE_INT_4;
+
case GL_VIEWPORT:
if (index >= ctx->Const.MaxViewports)
goto invalid_value;
goto invalid_value;
if (!ctx->Extensions.ARB_uniform_buffer_object)
goto invalid_enum;
- v->value_int = ctx->UniformBufferBindings[index].Offset;
+ v->value_int = ctx->UniformBufferBindings[index].Offset < 0 ? 0 :
+ ctx->UniformBufferBindings[index].Offset;
return TYPE_INT;
case GL_UNIFORM_BUFFER_SIZE:
goto invalid_value;
if (!ctx->Extensions.ARB_uniform_buffer_object)
goto invalid_enum;
- v->value_int = ctx->UniformBufferBindings[index].Size;
+ v->value_int = ctx->UniformBufferBindings[index].Size < 0 ? 0 :
+ ctx->UniformBufferBindings[index].Size;
return TYPE_INT;
/* ARB_shader_storage_buffer_object */