mesa: always support occlusion queries

Excerpt from ARB_occlusion_query.txt:
  An implementation can either set QUERY_COUNTER_BITS_ARB to the
  value 0, or to some number greater than or equal to n.  If an
  implementation returns 0 for QUERY_COUNTER_BITS_ARB, then the
  occlusion queries will always return that zero samples passed the
  occlusion test, and so an application should not use occlusion queries
  on that implementation.

This looks more sane for drivers wanting desktop gl 1.5 without real
hw support then just faking it.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14361>
This commit is contained in:
Christian Gmeiner 2021-12-31 09:39:58 +01:00 committed by Marge Bot
parent 56886459c5
commit 0186e9e1c5
4 changed files with 11 additions and 3 deletions

View File

@ -277,6 +277,7 @@ _mesa_init_extensions(struct gl_extensions *extensions)
extensions->ARB_internalformat_query = GL_TRUE;
extensions->ARB_internalformat_query2 = GL_TRUE;
extensions->ARB_map_buffer_range = GL_TRUE;
extensions->ARB_occlusion_query = GL_TRUE;
extensions->ARB_sync = GL_TRUE;
extensions->ARB_texture_env_crossbar = GL_TRUE;
extensions->ARB_vertex_program = GL_TRUE;

View File

@ -31,6 +31,8 @@
#include "queryobj.h"
#include "mtypes.h"
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "state_tracker/st_cb_queryobj.h"
@ -914,10 +916,16 @@ _mesa_GetQueryBufferObjectui64v(GLuint id, GLuint buffer, GLenum pname,
void
_mesa_init_queryobj(struct gl_context *ctx)
{
struct pipe_screen *screen = ctx->pipe->screen;
ctx->Query.QueryObjects = _mesa_NewHashTable();
ctx->Query.CurrentOcclusionObject = NULL;
ctx->Const.QueryCounterBits.SamplesPassed = 64;
if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY))
ctx->Const.QueryCounterBits.SamplesPassed = 64;
else
ctx->Const.QueryCounterBits.SamplesPassed = 0;
ctx->Const.QueryCounterBits.TimeElapsed = 64;
ctx->Const.QueryCounterBits.Timestamp = 64;
ctx->Const.QueryCounterBits.PrimitivesGenerated = 64;

View File

@ -933,12 +933,12 @@ st_create_context(gl_api api, struct pipe_context *pipe,
return NULL;
memset(ctx, 0, sizeof(*ctx));
ctx->pipe = pipe;
if (!_mesa_initialize_context(ctx, api, visual, shareCtx, &funcs)) {
align_free(ctx);
return NULL;
}
ctx->pipe = pipe;
st_debug_init();
if (pipe->screen->get_disk_shader_cache)

View File

@ -798,7 +798,6 @@ void st_init_extensions(struct pipe_screen *screen,
{ o(ARB_gl_spirv), PIPE_CAP_GL_SPIRV },
{ o(ARB_indirect_parameters), PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS },
{ o(ARB_instanced_arrays), PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR },
{ o(ARB_occlusion_query), PIPE_CAP_OCCLUSION_QUERY },
{ o(ARB_occlusion_query2), PIPE_CAP_OCCLUSION_QUERY },
{ o(ARB_pipeline_statistics_query), PIPE_CAP_QUERY_PIPELINE_STATISTICS },
{ o(ARB_pipeline_statistics_query), PIPE_CAP_QUERY_PIPELINE_STATISTICS_SINGLE },