You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classShaderProcessor{/** * Process the lines with uniforms. The function receives the lines containing all uniforms, * both numerical as well as textures/samplers. The function also receives the format of uniform * buffers (numerical) and bind groups (textures) for view and material level. All uniforms that * match any of those are ignored, as those would be supplied by view / material level buffers. * All leftover uniforms create uniform buffer and bind group for the mesh itself, containing * uniforms that change on the level of the mesh. * * @param {import('./graphics-device.js').GraphicsDevice} device - The graphics device. * @param {Array<UniformLine>} uniforms - Lines containing uniforms. * @param {import('./shader-processor-options.js').ShaderProcessorOptions} processingOptions - * Uniform formats. * @param {import('./shader.js').Shader} shader - The shader definition. * @returns {object} - The uniform data. Returns a shader code block containing uniforms, to be * inserted into the shader, as well as generated uniform format structures for the mesh level. */staticprocessUniforms(device,uniforms,processingOptions,shader){// split uniform lines into samplers and the rest/** @type {Array<UniformLine>} */constuniformLinesSamplers=[];/** @type {Array<UniformLine>} */constuniformLinesNonSamplers=[];uniforms.forEach((uniform)=>{if(uniform.isSampler){uniformLinesSamplers.push(uniform);}else{uniformLinesNonSamplers.push(uniform);}});// build mesh uniform buffer formatconstmeshUniforms=[];uniformLinesNonSamplers.forEach((uniform)=>{// uniforms not already in supplied uniform buffers go to the mesh bufferif(!processingOptions.hasUniform(uniform.name)){constuniformType=uniformTypeToName.indexOf(uniform.type);constuniformFormat=newUniformFormat(uniform.name,uniformType,uniform.arraySize);meshUniforms.push(uniformFormat);}});constmeshUniformBufferFormat=meshUniforms.length ? newUniformBufferFormat(device,meshUniforms) : null;// build mesh bind group format - start with uniform bufferconstbufferFormats=[];if(meshUniformBufferFormat){// TODO: we could optimize visibility to only stages that use any of the databufferFormats.push(newBindBufferFormat(UNIFORM_BUFFER_DEFAULT_SLOT_NAME,SHADERSTAGE_VERTEX|SHADERSTAGE_FRAGMENT));}// add textures uniformsconsttextureFormats=[];uniformLinesSamplers.forEach((uniform)=>{// unmatched texture uniforms go to mesh blockif(!processingOptions.hasTexture(uniform.name)){// sample type// WebGpu does not currently support filtered float format textures, and so we map them to unfilterable type// as we sample them without filtering anywaysletsampleType=SAMPLETYPE_FLOAT;if(uniform.precision==='highp')sampleType=SAMPLETYPE_UNFILTERABLE_FLOAT;if(shadowSamplers.has(uniform.type))sampleType=SAMPLETYPE_DEPTH;// dimensionconstdimension=textureDimensions[uniform.type];// TODO: we could optimize visibility to only stages that use any of the datatextureFormats.push(newBindTextureFormat(uniform.name,SHADERSTAGE_VERTEX|SHADERSTAGE_FRAGMENT,dimension,sampleType));}// validate types in else});constmeshBindGroupFormat=newBindGroupFormat(device,bufferFormats,textureFormats);// generate code for uniform buffersletcode='';processingOptions.uniformFormats.forEach((format,bindGroupIndex)=>{if(format){code+=format.getShaderDeclaration(bindGroupIndex,0);}});// and also for generated mesh format, which is at the slot 0 of the bind groupif(meshUniformBufferFormat){code+=meshUniformBufferFormat.getShaderDeclaration(BINDGROUP_MESH,0);}// generate code for texturesprocessingOptions.bindGroupFormats.forEach((format,bindGroupIndex)=>{if(format){code+=format.getShaderDeclarationTextures(bindGroupIndex);}});// and also for generated mesh formatcode+=meshBindGroupFormat.getShaderDeclarationTextures(BINDGROUP_MESH);return{
code,
meshUniformBufferFormat,
meshBindGroupFormat
};}}export{ShaderProcessor};
Currently produces eleven of these warnings:
generateTypeChecks> getName> missing parent for ArrowFunctionExpression> Missing param: uniforms
The text was updated successfully, but these errors were encountered:
Simplified test code for warnings:
Currently produces eleven of these warnings:
The text was updated successfully, but these errors were encountered: