-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for a bug in Adreno's shader compiler
At least some adreno compilers don't like returning an element of a UBO array that is a structure in the vertex shader. To work this around we have to copy the each of the structure fields. Fixes #6355
- Loading branch information
1 parent
aa5504a
commit 3b219bf
Showing
13 changed files
with
69 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//------------------------------------------------------------------------------ | ||
// Instancing | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
PerRenderableData object_uniforms; | ||
|
||
void initObjectUniforms(out PerRenderableData p) { | ||
#if defined(MATERIAL_HAS_INSTANCES) | ||
// the material manages instancing, all instances share the same uniform block. | ||
p = objectUniforms.data[0]; | ||
#else | ||
// automatic instancing was used, each instance has its own uniform block. | ||
|
||
// We're copying each field separately to workaround an issue in some Adreno drivers | ||
// that fail on non-const array access in a UBO. Accessing the fields works however. | ||
// e.g.: this fails `p = objectUniforms.data[instance_index];` | ||
p.worldFromModelMatrix = objectUniforms.data[instance_index].worldFromModelMatrix; | ||
p.worldFromModelNormalMatrix = objectUniforms.data[instance_index].worldFromModelNormalMatrix; | ||
p.morphTargetCount = objectUniforms.data[instance_index].morphTargetCount; | ||
p.flagsChannels = objectUniforms.data[instance_index].flagsChannels; | ||
p.objectId = objectUniforms.data[instance_index].objectId; | ||
p.userData = objectUniforms.data[instance_index].userData; | ||
#endif | ||
} | ||
|
||
//------------------------------------------------------------------------------ | ||
// Instance access | ||
//------------------------------------------------------------------------------ | ||
|
||
#if defined(MATERIAL_HAS_INSTANCES) | ||
/** @public-api */ | ||
int getInstanceIndex() { | ||
return instance_index; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters