[virglrenderer-devel] [PATCH 2/4] vrend: Rework caps for running on GLES hosts
Dave Airlie
airlied at gmail.com
Fri Mar 9 19:48:03 UTC 2018
On 9 March 2018 at 23:30, Jakob Bornecrantz <jakob at collabora.com> wrote:
> Signed-off-by: Jakob Bornecrantz <jakob at collabora.com>
Wow that gets ugly quick,
Maybe we could just have a separate path for gles and gl here, so if
(vrend_state_use_gles)
set_all_the_gles_caps();
Dave.
> ---
> src/vrend_renderer.c | 116 +++++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 90 insertions(+), 26 deletions(-)
>
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index 57492c7..123387f 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -6352,8 +6352,14 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> caps->max_version = 2;
> }
>
> + // We can't fully support this feature on GLES,
> + // but it is needed for OpenGL 2.1 so lie.
> caps->v1.bset.occlusion_query = 1;
> - if (gl_ver >= 30) {
> +
> + if (vrend_state.use_gles) {
> + caps->v1.bset.indep_blend_enable = 0;
> + caps->v1.bset.conditional_render = 0;
> + } else if (gl_ver >= 30) {
> caps->v1.bset.indep_blend_enable = 1;
> caps->v1.bset.conditional_render = 1;
> } else {
> @@ -6363,14 +6369,20 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> caps->v1.bset.conditional_render = 1;
> }
>
> - if (vrend_state.use_core_profile) {
> + if (vrend_state.use_gles) {
> + caps->v1.bset.poly_stipple = 0;
> + caps->v1.bset.color_clamping = 0;
> + } else if (vrend_state.use_core_profile) {
> caps->v1.bset.poly_stipple = 0;
> caps->v1.bset.color_clamping = 0;
> } else {
> caps->v1.bset.poly_stipple = 1;
> caps->v1.bset.color_clamping = 1;
> }
> - if (gl_ver >= 31) {
> +
> + if (vrend_state.use_gles) {
> + caps->v1.bset.instanceid = 0;
> + } else if (gl_ver >= 31) {
> caps->v1.bset.instanceid = 1;
> glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS, &max);
> vrend_state.max_uniform_blocks = max;
> @@ -6380,10 +6392,18 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> caps->v1.bset.instanceid = 1;
> }
>
> - if (vrend_state.have_nv_prim_restart || vrend_state.have_gl_prim_restart)
> + if (vrend_state.use_gles) {
> + caps->v1.bset.primitive_restart = 0;
> + } else if (vrend_state.have_nv_prim_restart ||
> + vrend_state.have_gl_prim_restart) {
> caps->v1.bset.primitive_restart = 1;
> + }
>
> - if (gl_ver >= 32) {
> + if (vrend_state.use_gles) {
> + caps->v1.bset.fragment_coord_conventions = 0;
> + caps->v1.bset.depth_clip_disable = 0;
> + caps->v1.bset.seamless_cube_map = 0;
> + } else if (gl_ver >= 32) {
> caps->v1.bset.fragment_coord_conventions = 1;
> caps->v1.bset.depth_clip_disable = 1;
> caps->v1.bset.seamless_cube_map = 1;
> @@ -6394,14 +6414,25 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> caps->v1.bset.seamless_cube_map = 1;
> }
>
> - if (epoxy_has_gl_extension("GL_AMD_seamless_cube_map_per_texture"))
> + if (vrend_state.use_gles) {
> + caps->v1.bset.seamless_cube_map_per_texture = 0;
> + } else if (epoxy_has_gl_extension("GL_AMD_seamless_cube_map_per_texture")) {
> caps->v1.bset.seamless_cube_map_per_texture = 1;
> + }
>
> - if (epoxy_has_gl_extension("GL_ARB_texture_multisample")) {
> - /* disable multisample until developed */
> + if (vrend_state.use_gles) {
> + caps->v1.bset.texture_multisample = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_texture_multisample")) {
> caps->v1.bset.texture_multisample = 1;
> }
> - if (gl_ver >= 40) {
> +
> + if (vrend_state.use_gles) {
> + caps->v1.bset.indep_blend_func = 0;
> + caps->v1.bset.cube_map_array = 0;
> + caps->v1.bset.texture_query_lod = 0;
> + caps->v1.bset.has_indirect_draw = 0;
> + caps->v1.bset.has_sample_shading = 0;
> + } else if (gl_ver >= 40) {
> caps->v1.bset.indep_blend_func = 1;
> caps->v1.bset.cube_map_array = 1;
> caps->v1.bset.texture_query_lod = 1;
> @@ -6420,24 +6451,34 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> caps->v1.bset.has_sample_shading = 1;
> }
>
> - if (gl_ver >= 42) {
> + if (vrend_state.use_gles) {
> + caps->v1.bset.start_instance = 0;
> + } else if (gl_ver >= 42) {
> caps->v1.bset.start_instance = 1;
> } else {
> if (epoxy_has_gl_extension("GL_ARB_base_instance"))
> caps->v1.bset.start_instance = 1;
> }
> - if (epoxy_has_gl_extension("GL_ARB_shader_stencil_export"))
> +
> +
> + if (vrend_state.use_gles) {
> + caps->v1.bset.shader_stencil_export = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_shader_stencil_export")) {
> caps->v1.bset.shader_stencil_export = 1;
> + }
>
> - /* we only support up to GLSL 1.40 features now */
> - caps->v1.glsl_level = 130;
> - if (vrend_state.use_core_profile) {
> +
> + if (vrend_state.use_gles) {
> + caps->v1.glsl_level = 120;
> + } else if (vrend_state.use_core_profile) {
> if (gl_ver == 31)
> caps->v1.glsl_level = 140;
> else if (gl_ver == 32)
> caps->v1.glsl_level = 150;
> else if (gl_ver >= 33)
> caps->v1.glsl_level = 330;
> + } else {
> + caps->v1.glsl_level = 130;
> }
>
> if (epoxy_has_gl_extension("GL_EXT_texture_mirror_clamp"))
> @@ -6449,20 +6490,28 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> }
>
> /* we need tf3 so we can do gallium skip buffers */
> - if (epoxy_has_gl_extension("GL_ARB_transform_feedback2")) {
> + if (vrend_state.use_gles) {
> + caps->v1.bset.streamout_pause_resume = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_transform_feedback2")) {
> caps->v1.bset.streamout_pause_resume = 1;
> }
>
> - if (epoxy_has_gl_extension("GL_ARB_transform_feedback3")) {
> + if (vrend_state.use_gles) {
> + caps->v1.max_dual_source_render_targets = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_transform_feedback3")) {
> glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max);
> caps->v1.max_streamout_buffers = max;
> } else if (epoxy_has_gl_extension("GL_EXT_transform_feedback"))
> caps->v1.max_streamout_buffers = 4;
> - if (epoxy_has_gl_extension("GL_ARB_blend_func_extended")) {
> +
> + if (vrend_state.use_gles) {
> + caps->v1.max_dual_source_render_targets = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_blend_func_extended")) {
> glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max);
> caps->v1.max_dual_source_render_targets = max;
> - } else
> + } else {
> caps->v1.max_dual_source_render_targets = 0;
> + }
>
> glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max);
> caps->v1.max_render_targets = max;
> @@ -6470,34 +6519,49 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
> glGetIntegerv(GL_MAX_SAMPLES, &max);
> caps->v1.max_samples = max;
>
> - if (epoxy_has_gl_extension("GL_ARB_texture_buffer_object")) {
> + if (vrend_state.use_gles) {
> + caps->v1.max_tbo_size = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_texture_buffer_object")) {
> glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max);
> caps->v1.max_tbo_size = max;
> + } else {
> + caps->v1.max_tbo_size = 0;
> }
>
> - if (epoxy_has_gl_extension("GL_ARB_texture_gather")) {
> + if (vrend_state.use_gles) {
> + caps->v1.max_tbo_size = 0;
> + } else if (epoxy_has_gl_extension("GL_ARB_texture_gather")) {
> glGetIntegerv(GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB, &max);
> caps->v1.max_texture_gather_components = max;
> + } else {
> + caps->v1.max_tbo_size = 0;
> }
>
> - if (epoxy_has_gl_extension("GL_ARB_viewport_array")) {
> + if (vrend_state.use_gles) {
> + caps->v1.max_viewports = 1;
> + } else if (epoxy_has_gl_extension("GL_ARB_viewport_array")) {
> glGetIntegerv(GL_MAX_VIEWPORTS, &max);
> caps->v1.max_viewports = max;
> - } else
> + } else {
> caps->v1.max_viewports = 1;
> + }
>
> caps->v1.prim_mask = (1 << PIPE_PRIM_POINTS) | (1 << PIPE_PRIM_LINES) | (1 << PIPE_PRIM_LINE_STRIP) | (1 << PIPE_PRIM_LINE_LOOP) | (1 << PIPE_PRIM_TRIANGLES) | (1 << PIPE_PRIM_TRIANGLE_STRIP) | (1 << PIPE_PRIM_TRIANGLE_FAN);
> - if (vrend_state.use_core_profile == false) {
> +
> + if (vrend_state.use_gles == false &&
> + vrend_state.use_core_profile == false) {
> caps->v1.prim_mask |= (1 << PIPE_PRIM_QUADS) | (1 << PIPE_PRIM_QUAD_STRIP) | (1 << PIPE_PRIM_POLYGON);
> }
> - if (caps->v1.glsl_level >= 150)
> +
> + if (!vrend_state.use_gles && caps->v1.glsl_level >= 150) {
> caps->v1.prim_mask |= (1 << PIPE_PRIM_LINES_ADJACENCY) |
> (1 << PIPE_PRIM_LINE_STRIP_ADJACENCY) |
> (1 << PIPE_PRIM_TRIANGLES_ADJACENCY) |
> (1 << PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY);
> + }
>
> -
> - if (epoxy_has_gl_extension("GL_ARB_vertex_type_10f_11f_11f_rev")) {
> + if (!vrend_state.use_gles &&
> + epoxy_has_gl_extension("GL_ARB_vertex_type_10f_11f_11f_rev")) {
> int val = VIRGL_FORMAT_R11G11B10_FLOAT;
> uint32_t offset = val / 32;
> uint32_t index = val % 32;
> --
> 2.14.1
>
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel
More information about the virglrenderer-devel
mailing list