Skip to content

Commit 1b34d2a

Browse files
lexaknyazevAngle LUCI CQ
authored andcommitted
Ensure ValidateUniform* consistency
Uniform calls are valid when location is -1 or ignored. Bug: angleproject:406922380 Change-Id: I7f829f7f8a67ba6bac39ff8ee06c7f26c1421417 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6408952 Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 parent 64dc609 commit 1b34d2a

3 files changed

Lines changed: 62 additions & 22 deletions

File tree

src/libANGLE/validationES.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,9 +2970,16 @@ bool ValidateUniform(const Context *context,
29702970
{
29712971
const LinkedUniform *uniform = nullptr;
29722972
Program *programObject = context->getActiveLinkedProgram();
2973-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
2974-
&uniform) &&
2975-
ValidateUniformValue(context, entryPoint, valueType, uniform->getType());
2973+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
2974+
{
2975+
// Error already generated.
2976+
return false;
2977+
}
2978+
if (uniform == nullptr)
2979+
{
2980+
return true; // no-op
2981+
}
2982+
return ValidateUniformValue(context, entryPoint, valueType, uniform->getType());
29762983
}
29772984

29782985
bool ValidateUniform1iv(const Context *context,
@@ -2983,9 +2990,16 @@ bool ValidateUniform1iv(const Context *context,
29832990
{
29842991
const LinkedUniform *uniform = nullptr;
29852992
Program *programObject = context->getActiveLinkedProgram();
2986-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
2987-
&uniform) &&
2988-
ValidateUniform1ivValue(context, entryPoint, uniform->getType(), count, value);
2993+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
2994+
{
2995+
// Error already generated.
2996+
return false;
2997+
}
2998+
if (uniform == nullptr)
2999+
{
3000+
return true; // no-op
3001+
}
3002+
return ValidateUniform1ivValue(context, entryPoint, uniform->getType(), count, value);
29893003
}
29903004

29913005
bool ValidateUniformMatrix(const Context *context,
@@ -3003,9 +3017,16 @@ bool ValidateUniformMatrix(const Context *context,
30033017

30043018
const LinkedUniform *uniform = nullptr;
30053019
Program *programObject = context->getActiveLinkedProgram();
3006-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
3007-
&uniform) &&
3008-
ValidateUniformMatrixValue(context, entryPoint, valueType, uniform->getType());
3020+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
3021+
{
3022+
// Error already generated.
3023+
return false;
3024+
}
3025+
if (uniform == nullptr)
3026+
{
3027+
return true; // no-op
3028+
}
3029+
return ValidateUniformMatrixValue(context, entryPoint, valueType, uniform->getType());
30093030
}
30103031

30113032
bool ValidateStateQuery(const Context *context,

src/libANGLE/validationES.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ ANGLE_INLINE bool ValidateUniformCommonBase(const Context *context,
346346

347347
if (location.value == -1)
348348
{
349-
// Silently ignore the uniform command
350-
return false;
349+
return true; // no-op
351350
}
352351

353352
const ProgramExecutable &executable = program->getExecutable();
@@ -362,8 +361,7 @@ ANGLE_INLINE bool ValidateUniformCommonBase(const Context *context,
362361
const auto &uniformLocation = uniformLocations[castedLocation];
363362
if (uniformLocation.ignored)
364363
{
365-
// Silently ignore the uniform command
366-
return false;
364+
return true; // no-op
367365
}
368366

369367
if (!uniformLocation.used())

src/libANGLE/validationES31.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,16 @@ bool ValidateProgramUniformBase(const Context *context,
327327
{
328328
const LinkedUniform *uniform = nullptr;
329329
Program *programObject = GetValidProgram(context, entryPoint, program);
330-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
331-
&uniform) &&
332-
ValidateUniformValue(context, entryPoint, valueType, uniform->getType());
330+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
331+
{
332+
// Error already generated.
333+
return false;
334+
}
335+
if (uniform == nullptr)
336+
{
337+
return true; // no-op
338+
}
339+
return ValidateUniformValue(context, entryPoint, valueType, uniform->getType());
333340
}
334341

335342
bool ValidateProgramUniformMatrixBase(const Context *context,
@@ -342,9 +349,16 @@ bool ValidateProgramUniformMatrixBase(const Context *context,
342349
{
343350
const LinkedUniform *uniform = nullptr;
344351
Program *programObject = GetValidProgram(context, entryPoint, program);
345-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
346-
&uniform) &&
347-
ValidateUniformMatrixValue(context, entryPoint, valueType, uniform->getType());
352+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
353+
{
354+
// Error already generated.
355+
return false;
356+
}
357+
if (uniform == nullptr)
358+
{
359+
return true; // no-op
360+
}
361+
return ValidateUniformMatrixValue(context, entryPoint, valueType, uniform->getType());
348362
}
349363

350364
bool ValidateVertexAttribFormatCommon(const Context *context,
@@ -742,9 +756,16 @@ bool ValidateProgramUniform1ivBase(const Context *context,
742756
{
743757
const LinkedUniform *uniform = nullptr;
744758
Program *programObject = GetValidProgram(context, entryPoint, program);
745-
return ValidateUniformCommonBase(context, entryPoint, programObject, location, count,
746-
&uniform) &&
747-
ValidateUniform1ivValue(context, entryPoint, uniform->getType(), count, value);
759+
if (!ValidateUniformCommonBase(context, entryPoint, programObject, location, count, &uniform))
760+
{
761+
// Error already generated.
762+
return false;
763+
}
764+
if (uniform == nullptr)
765+
{
766+
return true; // no-op
767+
}
768+
return ValidateUniform1ivValue(context, entryPoint, uniform->getType(), count, value);
748769
}
749770

750771
bool ValidateProgramUniform2ivBase(const Context *context,

0 commit comments

Comments
 (0)