<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Recently, I've been working on scripts for a GLSL fuzz testing framework that use piglit's shader_runner to render shaders. As part of the test generation process, shaders can be generated that declare uniforms without using them (which is valid GLSL according
 to glslangvalidator). One of my scripts turns the shader and uniform data from the framework's test format into a shader_test file and runs it via shader_runner_gles3.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
However, it seems that some of these unused uniforms are optimized away when the shader is compiled, and when shader_runner tries to use the uniform data in the [test] header, it can't find the location of the given uniform and throws an error.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Relevant code (there are similar pieces of code in the file for vertex and subuniforms):</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
piglit/tests/shaders/shader_runner.c, line 2289:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>> loc = glGetUniformLocation(prog, name);<br>
</span>
<div>> if (loc < 0) {<br>
</div>
<div>>  printf("cannot get location of uniform \"%s\"\n",<br>
</div>
<div>>         name);<br>
</div>
<div>>  piglit_report_result(PIGLIT_FAIL);<br>
</div>
<span>> }</span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I'd like to discuss whether it'd be possible to instead just ignore a piece of uniform data if the corresponding uniform can't be found in the compiled shader (I'd be willing to submit a patch for this).
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Something like:<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>> loc = glGetUniformLocation(prog, name);<br>
</span>
<div>> if (loc < 0) {<br>
</div>
<div>>  printf("cannot get location of uniform \"%s\"\n",<br>
</div>
<div>>         name);<br>
</div>
<div>>  return;<br>
</div>
<span>> }</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>From my limited grepping of the code, there doesn't seem to be anything that would fail horribly if this were to be changed (as the setting of a uniform only occurs at the end of set_uniform, after various checks like this), but please correct me if I'm
 wrong about any of this.<br>
</span></div>
</body>
</html>