Skip to content
Snippets Groups Projects
Commit a4ab117d authored by Alexander Rose's avatar Alexander Rose
Browse files

support WEBGL_provoking_vertex

parent 8e1876fc
Branches
No related tags found
No related merge requests found
/** /**
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
...@@ -523,6 +523,31 @@ export function getFboRenderMipmap(gl: GLRenderingContext): COMPAT_fboRenderMipm ...@@ -523,6 +523,31 @@ export function getFboRenderMipmap(gl: GLRenderingContext): COMPAT_fboRenderMipm
return isWebGL2(gl) ? {} : gl.getExtension('OES_fbo_render_mipmap'); return isWebGL2(gl) ? {} : gl.getExtension('OES_fbo_render_mipmap');
} }
/**
* See https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
*/
export interface COMPAT_provoking_vertex {
readonly FIRST_VERTEX_CONVENTION: number;
readonly LAST_VERTEX_CONVENTION: number;
readonly PROVOKING_VERTEX: number;
provokingVertex(provokeMode: number): void;
}
export function getProvokingVertex(gl: GLRenderingContext): COMPAT_provoking_vertex | null {
if (isWebGL2(gl)) {
const ext = gl.getExtension('WEBGL_provoking_vertex');
if (ext) {
return {
FIRST_VERTEX_CONVENTION: ext.FIRST_VERTEX_CONVENTION_WEBGL,
LAST_VERTEX_CONVENTION: ext.LAST_VERTEX_CONVENTION_WEBGL,
PROVOKING_VERTEX: ext.PROVOKING_VERTEX_WEBGL,
provokingVertex: ext.provokingVertexWEBGL.bind(gl)
};
}
}
return null;
}
export function getNoNonInstancedActiveAttribs(gl: GLRenderingContext): boolean { export function getNoNonInstancedActiveAttribs(gl: GLRenderingContext): boolean {
if (!isWebGL2(gl)) return false; if (!isWebGL2(gl)) return false;
......
...@@ -239,6 +239,11 @@ export function createContext(gl: GLRenderingContext, props: Partial<{ pixelScal ...@@ -239,6 +239,11 @@ export function createContext(gl: GLRenderingContext, props: Partial<{ pixelScal
throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8'); throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');
} }
// optimize assuming flats first and last data are same or differences don't matter
// extension is only available when `FIRST_VERTEX_CONVENTION` is more efficient
const epv = extensions.provokingVertex;
epv?.provokingVertex(epv.FIRST_VERTEX_CONVENTION);
let isContextLost = false; let isContextLost = false;
const contextRestored = new BehaviorSubject<now.Timestamp>(0 as now.Timestamp); const contextRestored = new BehaviorSubject<now.Timestamp>(0 as now.Timestamp);
......
/** /**
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2018-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import { GLRenderingContext, COMPAT_instanced_arrays, COMPAT_standard_derivatives, COMPAT_vertex_array_object, getInstancedArrays, getStandardDerivatives, COMPAT_element_index_uint, getElementIndexUint, COMPAT_texture_float, getTextureFloat, COMPAT_texture_float_linear, getTextureFloatLinear, COMPAT_blend_minmax, getBlendMinMax, getFragDepth, COMPAT_frag_depth, COMPAT_color_buffer_float, getColorBufferFloat, COMPAT_draw_buffers, getDrawBuffers, getShaderTextureLod, COMPAT_shader_texture_lod, getDepthTexture, COMPAT_depth_texture, COMPAT_sRGB, getSRGB, getTextureHalfFloat, getTextureHalfFloatLinear, COMPAT_texture_half_float, COMPAT_texture_half_float_linear, COMPAT_color_buffer_half_float, getColorBufferHalfFloat, getVertexArrayObject, getDisjointTimerQuery, COMPAT_disjoint_timer_query, getNoNonInstancedActiveAttribs, getDrawBuffersIndexed, COMPAT_draw_buffers_indexed, getParallelShaderCompile, COMPAT_parallel_shader_compile, getFboRenderMipmap, COMPAT_fboRenderMipmap } from './compat'; import { GLRenderingContext, COMPAT_instanced_arrays, COMPAT_standard_derivatives, COMPAT_vertex_array_object, getInstancedArrays, getStandardDerivatives, COMPAT_element_index_uint, getElementIndexUint, COMPAT_texture_float, getTextureFloat, COMPAT_texture_float_linear, getTextureFloatLinear, COMPAT_blend_minmax, getBlendMinMax, getFragDepth, COMPAT_frag_depth, COMPAT_color_buffer_float, getColorBufferFloat, COMPAT_draw_buffers, getDrawBuffers, getShaderTextureLod, COMPAT_shader_texture_lod, getDepthTexture, COMPAT_depth_texture, COMPAT_sRGB, getSRGB, getTextureHalfFloat, getTextureHalfFloatLinear, COMPAT_texture_half_float, COMPAT_texture_half_float_linear, COMPAT_color_buffer_half_float, getColorBufferHalfFloat, getVertexArrayObject, getDisjointTimerQuery, COMPAT_disjoint_timer_query, getNoNonInstancedActiveAttribs, getDrawBuffersIndexed, COMPAT_draw_buffers_indexed, getParallelShaderCompile, COMPAT_parallel_shader_compile, getFboRenderMipmap, COMPAT_fboRenderMipmap, COMPAT_provoking_vertex, getProvokingVertex } from './compat';
import { isDebugMode } from '../../mol-util/debug'; import { isDebugMode } from '../../mol-util/debug';
export type WebGLExtensions = { export type WebGLExtensions = {
...@@ -29,6 +29,7 @@ export type WebGLExtensions = { ...@@ -29,6 +29,7 @@ export type WebGLExtensions = {
disjointTimerQuery: COMPAT_disjoint_timer_query | null disjointTimerQuery: COMPAT_disjoint_timer_query | null
parallelShaderCompile: COMPAT_parallel_shader_compile | null parallelShaderCompile: COMPAT_parallel_shader_compile | null
fboRenderMipmap: COMPAT_fboRenderMipmap | null fboRenderMipmap: COMPAT_fboRenderMipmap | null
provokingVertex: COMPAT_provoking_vertex | null
noNonInstancedActiveAttribs: boolean noNonInstancedActiveAttribs: boolean
} }
...@@ -121,6 +122,10 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions { ...@@ -121,6 +122,10 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions {
if (isDebugMode && fboRenderMipmap === null) { if (isDebugMode && fboRenderMipmap === null) {
console.log('Could not find support for "fbo_render_mipmap"'); console.log('Could not find support for "fbo_render_mipmap"');
} }
const provokingVertex = getProvokingVertex(gl);
if (isDebugMode && provokingVertex === null) {
console.log('Could not find support for "provoking_vertex"');
}
const noNonInstancedActiveAttribs = getNoNonInstancedActiveAttribs(gl); const noNonInstancedActiveAttribs = getNoNonInstancedActiveAttribs(gl);
...@@ -146,6 +151,7 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions { ...@@ -146,6 +151,7 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions {
disjointTimerQuery, disjointTimerQuery,
parallelShaderCompile, parallelShaderCompile,
fboRenderMipmap, fboRenderMipmap,
provokingVertex,
noNonInstancedActiveAttribs, noNonInstancedActiveAttribs,
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment