3 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGL
5 using System.Collections.Generic;
9 using SiliconStudio.Core;
10 using SiliconStudio.Core.Diagnostics;
11 using SiliconStudio.Core.Extensions;
12 using SiliconStudio.Paradox.Shaders;
13 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
14 using OpenTK.Graphics.ES30;
16 using OpenTK.Graphics.OpenGL;
20 namespace SiliconStudio.
Paradox.Graphics
22 internal partial class EffectProgram
26 private readonly EffectBytecode effectBytecode;
28 private EffectInputSignature inputSignature;
30 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
34 public ActiveUniformType
Type;
35 public int UniformIndex;
38 public int CompareSize;
41 internal byte[] BoundUniforms;
42 internal List<Uniform> Uniforms =
new List<Uniform>();
47 public int TextureUnit;
51 TextureUnit = textureUnit;
55 internal List<Texture> Textures =
new List<Texture>();
57 private EffectProgram(GraphicsDevice device, EffectBytecode bytecode)
60 effectBytecode = bytecode;
64 private void CreateShaders()
66 using (GraphicsDevice.UseOpenGLCreationContext())
68 resourceId = GL.CreateProgram();
71 foreach (var shader
in effectBytecode.Stages)
73 ShaderType shaderStage;
76 case ShaderStage.Vertex:
77 shaderStage = ShaderType.VertexShader;
78 inputSignature = EffectInputSignature.GetOrCreateLayout(
new EffectInputSignature(shader.Id, shader.Data));
80 case ShaderStage.Pixel:
81 shaderStage = ShaderType.FragmentShader;
84 throw new Exception(
"Unsupported shader stage");
88 var shaderSource = shader.GetDataAsString();
90 var shaderId = GL.CreateShader(shaderStage);
91 GL.ShaderSource(shaderId, shaderSource);
92 GL.CompileShader(shaderId);
95 GL.GetShader(shaderId, ShaderParameter.CompileStatus, out compileStatus);
96 if (compileStatus != 1)
98 var glErrorMessage = GL.GetShaderInfoLog(shaderId);
99 throw new InvalidOperationException(
"Error while compiling GLSL shader. [{0}]".ToFormat(glErrorMessage));
102 GL.AttachShader(resourceId, shaderId);
105 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
107 GL.ProgramParameter(resourceId, AssemblyProgramParameterArb.ProgramBinaryRetrievableHint, 1);
111 GL.LinkProgram(resourceId);
115 GL.GetProgram(resourceId, ProgramParameter.LinkStatus, out linkStatus);
118 var infoLog = GL.GetProgramInfoLog(resourceId);
119 throw new InvalidOperationException(
"Error while linking GLSL shaders.\n" + infoLog);
122 if (inputSignature.Attributes.Count == 0)
125 int activeAttribCount;
126 GL.GetProgram(resourceId, ProgramParameter.ActiveAttributes, out activeAttribCount);
128 for (
int activeAttribIndex = 0; activeAttribIndex < activeAttribCount; ++activeAttribIndex)
131 ActiveAttribType type;
132 var attribName = GL.GetActiveAttrib(resourceId, activeAttribIndex, out
size, out type);
133 #if SILICONSTUDIO_PLATFORM_ANDROID
134 var attribIndex = GL.GetAttribLocation(resourceId,
new StringBuilder(attribName));
136 var attribIndex = GL.GetAttribLocation(resourceId, attribName);
138 inputSignature.Attributes.Add(attribName, attribIndex);
141 CreateReflection(effectBytecode.Reflection, effectBytecode.Stages[0].Stage);
143 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
145 BoundUniforms =
new byte[effectBytecode.Reflection.ConstantBuffers[0].Size];
152 foreach (var message
in reflectionResult.Messages)
153 Console.WriteLine(message);
154 if (reflectionResult.HasErrors)
158 public EffectInputSignature InputSignature
160 get {
return inputSignature; }
164 protected internal override bool OnRecreate()
172 protected override void Destroy()
174 using (GraphicsDevice.UseOpenGLCreationContext())
176 GL.DeleteProgram(resourceId);
184 public void Apply(GraphicsDevice device)
187 device.EnsureContextActive();
190 device.effectProgram =
this;
191 device.BindProgram(ResourceId);
199 private void CreateReflection(EffectReflection effectReflection,
ShaderStage stage)
202 GL.GetInteger(GetPName.CurrentProgram, out currentProgram);
203 GL.UseProgram(resourceId);
205 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
206 int uniformBlockCount;
207 GL.GetProgram(resourceId, ProgramParameter.ActiveUniformBlocks, out uniformBlockCount);
209 for (
int uniformBlockIndex = 0; uniformBlockIndex < uniformBlockCount; ++uniformBlockIndex)
212 var constantBufferName = GL.GetActiveUniformBlockName(resourceId, uniformBlockIndex);
214 var constantBufferDescriptionIndex = effectReflection.ConstantBuffers.FindIndex(x => x.Name == constantBufferName);
215 if (constantBufferDescriptionIndex == -1)
217 reflectionResult.Error(
"Unable to find the constant buffer description [{0}]", constantBufferName);
220 var constantBufferIndex = effectReflection.ResourceBindings.FindIndex(x => x.Param.RawName == constantBufferName);
221 if (constantBufferIndex == -1)
223 reflectionResult.Error(
"Unable to find the constant buffer [{0}]", constantBufferName);
227 var constantBufferDescription = effectReflection.ConstantBuffers[constantBufferDescriptionIndex];
228 var constantBuffer = effectReflection.ResourceBindings[constantBufferIndex];
230 GL.GetActiveUniformBlock(resourceId, uniformBlockIndex, ActiveUniformBlockParameter.UniformBlockDataSize, out constantBufferDescription.Size);
233 GL.GetActiveUniformBlock(resourceId, uniformBlockIndex, ActiveUniformBlockParameter.UniformBlockActiveUniforms, out uniformCount);
236 GL.UniformBlockBinding(resourceId, uniformBlockIndex, uniformBlockIndex);
239 var uniformIndices =
new int[uniformCount];
240 var uniformOffsets =
new int[uniformCount];
241 var uniformTypes =
new int[uniformCount];
242 var uniformNames =
new string[uniformCount];
243 GL.GetActiveUniformBlock(resourceId, uniformBlockIndex, ActiveUniformBlockParameter.UniformBlockActiveUniformIndices, uniformIndices);
244 GL.GetActiveUniforms(resourceId, uniformIndices.Length, uniformIndices, ActiveUniformParameter.UniformOffset, uniformOffsets);
245 GL.GetActiveUniforms(resourceId, uniformIndices.Length, uniformIndices, ActiveUniformParameter.UniformType, uniformTypes);
247 for (
int uniformIndex = 0; uniformIndex < uniformIndices.Length; ++uniformIndex)
249 uniformNames[uniformIndex] = GL.GetActiveUniformName(resourceId, uniformIndices[uniformIndex]);
253 var indexMapping = uniformIndices.Select((x, i) =>
new UniformMergeInfo { Offset = uniformOffsets[i],
Type = (ActiveUniformType)uniformTypes[i], Name = uniformNames[i], NextOffset = 0 }).OrderBy(x => x.Offset).ToArray();
254 indexMapping.Last().NextOffset = constantBufferDescription.Size;
257 for (
int i = 1; i < indexMapping.Length; ++i)
259 indexMapping[i - 1].NextOffset = indexMapping[i].Offset;
263 indexMapping = indexMapping.GroupBy(x =>
267 if (name.Contains(
".")) { name = name.Substring(0, name.IndexOf(
'.')); }
268 if (name.Contains(
"[")) { name = name.Substring(0, name.IndexOf(
'[')); }
273 var result = x.First();
274 result.NextOffset = x.Last().NextOffset;
277 int dotIndex = result.Name.IndexOf(
'.');
278 int arrayIndex = result.Name.IndexOf(
'[');
280 if (x.Count() > 1 && arrayIndex == -1 && dotIndex == -1)
281 throw new InvalidOperationException();
289 foreach (var variableIndexGroup
in indexMapping)
291 var variableIndex = -1;
292 for (var tentativeIndex = 0; tentativeIndex < constantBufferDescription.Members.Length; ++tentativeIndex)
294 if (constantBufferDescription.Members[tentativeIndex].Param.RawName == variableIndexGroup.Name)
296 variableIndex = tentativeIndex;
301 if (variableIndex == -1)
303 reflectionResult.Error(
"Unable to find uniform [{0}] in constant buffer [{1}]", variableIndexGroup.Name, constantBufferName);
306 var variable = constantBufferDescription.Members[variableIndex];
307 variable.Param.Type = GetTypeFromActiveUniformType(variableIndexGroup.Type);
308 variable.Offset = variableIndexGroup.Offset;
309 variable.Size = variable.Count * variable.RowCount * variable.ColumnCount * 4;
311 constantBufferDescription.Members[variableIndex] = variable;
314 constantBufferDescription.Stage = stage;
317 constantBuffer.SlotCount = 1;
318 constantBuffer.SlotStart = uniformBlockIndex;
319 constantBuffer.Stage = stage;
322 effectReflection.ConstantBuffers[constantBufferDescriptionIndex] = constantBufferDescription;
323 effectReflection.ResourceBindings[constantBufferIndex] = constantBuffer;
330 int activeUniformCount;
331 GL.GetProgram(resourceId, ProgramParameter.ActiveUniforms, out activeUniformCount);
332 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
333 var uniformTypes =
new int[activeUniformCount];
334 GL.GetActiveUniforms(resourceId, activeUniformCount, Enumerable.Range(0, activeUniformCount).ToArray(), ActiveUniformParameter.UniformType, uniformTypes);
337 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
349 foreach (var constantBuffer
in effectReflection.ConstantBuffers)
350 constantBuffer.Size = 0;
353 foreach (var constantBuffer
in effectReflection.ConstantBuffers)
354 constantBuffer.Stage = stage;
355 for (
int i = 0; i < effectReflection.ResourceBindings.Count; i++)
360 var globalConstantBufferCopy = effectReflection.ResourceBindings[i];
361 globalConstantBufferCopy.Stage = stage;
362 effectReflection.ResourceBindings[i] = globalConstantBufferCopy;
366 var globalConstantBufferDescriptionIndex = effectReflection.ConstantBuffers.FindIndex(x => x.Name ==
"Globals");
367 var globalConstantBufferIndex = effectReflection.ResourceBindings.FindIndex(x => x.Param.RawName ==
"Globals");
368 if (globalConstantBufferDescriptionIndex == -1 && globalConstantBufferIndex == -1)
370 var newConstantBufferDescription =
new ShaderConstantBufferDescription
376 Members =
new EffectParameterValueData[0],
378 var newConstantBuffer =
new EffectParameterResourceData
386 effectReflection.ConstantBuffers.Add(newConstantBufferDescription);
387 effectReflection.ResourceBindings.Add(newConstantBuffer);
389 globalConstantBufferDescriptionIndex = effectReflection.ConstantBuffers.Count - 1;
390 globalConstantBufferIndex = effectReflection.ResourceBindings.Count - 1;
394 if (globalConstantBufferDescriptionIndex != -1 && globalConstantBufferIndex != -1)
396 var globalConstantBufferDescription = effectReflection.ConstantBuffers[globalConstantBufferDescriptionIndex];
397 for (
int cstDescrIndex = 0; cstDescrIndex < effectReflection.ConstantBuffers.Count; ++cstDescrIndex)
399 if (cstDescrIndex == globalConstantBufferDescriptionIndex)
402 var currentConstantBufferDescription = effectReflection.ConstantBuffers[cstDescrIndex];
404 globalConstantBufferDescription.Members = ArrayExtensions.Concat(
405 globalConstantBufferDescription.Members, currentConstantBufferDescription.Members);
407 effectReflection.ResourceBindings.RemoveAll(x => x.Param.RawName == currentConstantBufferDescription.Name);
411 globalConstantBufferDescription.Members =
412 globalConstantBufferDescription.Members.Where(x => GL.GetUniformLocation(resourceId,
413 #if SILICONSTUDIO_PLATFORM_ANDROID
414 new StringBuilder(x.Param.RawName)
421 effectReflection.ConstantBuffers.Clear();
422 effectReflection.ConstantBuffers.Add(globalConstantBufferDescription);
424 else if (globalConstantBufferDescriptionIndex != -1 && globalConstantBufferIndex == -1)
426 reflectionResult.Error(
"Globals constant buffer has a description and no resource binding");
428 else if (globalConstantBufferDescriptionIndex == -1 && globalConstantBufferIndex != -1)
430 reflectionResult.Error(
"Globals constant buffer has a description and no resource binding");
434 int textureUnitCount = 0;
436 for (
int activeUniformIndex = 0; activeUniformIndex < activeUniformCount; ++activeUniformIndex)
438 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
439 var uniformType = (ActiveUniformType)uniformTypes[activeUniformIndex];
440 var uniformName = GL.GetActiveUniformName(resourceId, activeUniformIndex);
442 ActiveUniformType uniformType;
444 var uniformName = GL.GetActiveUniform(resourceId, activeUniformIndex, out uniformCount, out uniformType);
451 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
452 case ActiveUniformType.Bool:
453 case ActiveUniformType.Int:
454 AddUniform(effectReflection,
sizeof(
int) * 1, uniformCount, uniformName, uniformType);
456 case ActiveUniformType.BoolVec2:
457 case ActiveUniformType.IntVec2:
458 AddUniform(effectReflection,
sizeof(
int) * 2, uniformCount, uniformName, uniformType);
460 case ActiveUniformType.BoolVec3:
461 case ActiveUniformType.IntVec3:
462 AddUniform(effectReflection,
sizeof(
int) * 3, uniformCount, uniformName, uniformType);
464 case ActiveUniformType.BoolVec4:
465 case ActiveUniformType.IntVec4:
466 AddUniform(effectReflection,
sizeof(
int) * 4, uniformCount, uniformName, uniformType);
468 case ActiveUniformType.Float:
469 AddUniform(effectReflection,
sizeof(
float) * 1, uniformCount, uniformName, uniformType);
471 case ActiveUniformType.FloatVec2:
472 AddUniform(effectReflection,
sizeof(
float) * 2, uniformCount, uniformName, uniformType);
474 case ActiveUniformType.FloatVec3:
475 AddUniform(effectReflection,
sizeof(
float) * 3, uniformCount, uniformName, uniformType);
477 case ActiveUniformType.FloatVec4:
478 AddUniform(effectReflection,
sizeof(
float) * 4, uniformCount, uniformName, uniformType);
480 case ActiveUniformType.FloatMat4:
481 AddUniform(effectReflection,
sizeof(
float) * 4 * 4, uniformCount, uniformName, uniformType);
483 case ActiveUniformType.FloatMat2:
484 case ActiveUniformType.FloatMat3:
485 throw new NotImplementedException();
487 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
488 case ActiveUniformType.Sampler1D:
489 case ActiveUniformType.Sampler3D:
491 case ActiveUniformType.Sampler2D:
492 #if SILICONSTUDIO_PLATFORM_ANDROID
493 var uniformIndex = GL.GetUniformLocation(resourceId,
new StringBuilder(uniformName));
495 var uniformIndex = GL.GetUniformLocation(resourceId, uniformName);
501 var textureReflectionIndex = -1;
502 var samplerReflectionIndex = -1;
505 int middlePart = uniformName.IndexOf(
'_', startIndex + 1);
506 var textureName = middlePart != -1 ? uniformName.Substring(0, middlePart) : uniformName;
507 var samplerName = middlePart != -1 ? uniformName.Substring(middlePart + 1) : null;
509 textureReflectionIndex =
510 effectReflection.ResourceBindings.FindIndex(x => x.Param.RawName == textureName);
511 samplerReflectionIndex =
512 effectReflection.ResourceBindings.FindIndex(x => x.Param.RawName == samplerName);
514 if (textureReflectionIndex != -1 && samplerReflectionIndex != -1)
517 startIndex = middlePart;
518 }
while (startIndex != -1);
520 if (startIndex == -1 || textureReflectionIndex == -1 || samplerReflectionIndex == -1)
522 reflectionResult.Error(
"Unable to find sampler and texture corresponding to [{0}]", uniformName);
526 var textureReflection = effectReflection.ResourceBindings[textureReflectionIndex];
527 var samplerReflection = effectReflection.ResourceBindings[samplerReflectionIndex];
530 GL.Uniform1(uniformIndex, textureUnitCount);
532 textureReflection.Stage = stage;
534 textureReflection.Param.Type = GetTypeFromActiveUniformType(uniformType);
535 textureReflection.SlotStart = textureUnitCount;
536 textureReflection.SlotCount = 1;
537 textureReflection.Param.Class = EffectParameterClass.ShaderResourceView;
539 samplerReflection.Stage = stage;
540 samplerReflection.SlotStart = textureUnitCount;
541 samplerReflection.SlotCount = 1;
542 samplerReflection.Param.Class = EffectParameterClass.Sampler;
544 effectReflection.ResourceBindings[textureReflectionIndex] = textureReflection;
545 effectReflection.ResourceBindings[samplerReflectionIndex] = samplerReflection;
547 Textures.Add(
new Texture(textureUnitCount));
555 GL.UseProgram(currentProgram);
558 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
560 private void AddUniform(EffectReflection effectReflection,
int uniformSize,
int uniformCount,
string uniformName, ActiveUniformType uniformType)
563 if (uniformName.Contains(
"."))
565 uniformName = uniformName.Substring(0, uniformName.IndexOf(
'.'));
567 if (uniformName.Contains(
"["))
569 uniformName = uniformName.Substring(0, uniformName.IndexOf(
'['));
572 var indexOfConstantBufferDescription = effectReflection.ConstantBuffers.FindIndex(x => x.Name ==
"Globals");
573 var indexOfConstantBuffer = effectReflection.ResourceBindings.FindIndex(x => x.Param.RawName ==
"Globals");
575 if (indexOfConstantBufferDescription == -1 || indexOfConstantBuffer == -1)
577 reflectionResult.Error(
"Unable to find uniform [{0}] in any constant buffer", uniformName);
581 var constantBufferDescription = effectReflection.ConstantBuffers[indexOfConstantBufferDescription];
582 var constantBuffer = effectReflection.ResourceBindings[indexOfConstantBuffer];
584 var elementSize = uniformSize;
587 if (uniformSize % 16 != 0 && uniformCount > 1)
589 constantBufferDescription.Size = (constantBufferDescription.Size + 15) / 16 * 16;
590 uniformSize = (uniformSize + 15) / 16 * 16;
594 if (uniformCount == 1 && constantBufferDescription.Size / 16 != (constantBufferDescription.Size + uniformSize - 1) / 16)
595 constantBufferDescription.Size = (constantBufferDescription.Size + 15) / 16 * 16;
597 var indexOfUniform = -1;
598 for (var tentativeIndex = 0; tentativeIndex < constantBufferDescription.Members.Length; ++tentativeIndex)
600 if (constantBufferDescription.Members[tentativeIndex].Param.RawName == uniformName)
602 indexOfUniform = tentativeIndex;
607 var variable = constantBufferDescription.Members[indexOfUniform];
609 variable.Param.Type = GetTypeFromActiveUniformType(uniformType);
611 variable.Offset = constantBufferDescription.Size;
612 variable.Count = uniformCount;
613 variable.Size = uniformSize*uniformCount;
617 constantBuffer.SlotStart = 0;
619 constantBufferDescription.Members[indexOfUniform] = variable;
620 effectReflection.ResourceBindings[indexOfConstantBuffer] = constantBuffer;
624 var compareSize = uniformSize * (uniformCount - 1) + elementSize;
629 Count = uniformCount,
630 CompareSize = compareSize,
631 Offset = constantBufferDescription.Size,
632 #if SILICONSTUDIO_PLATFORM_ANDROID
633 UniformIndex = GL.GetUniformLocation(resourceId,
new StringBuilder(uniformName))
635 UniformIndex = GL.GetUniformLocation(resourceId, uniformName)
638 constantBufferDescription.Size += uniformSize * uniformCount;
642 private static int GetCountFromActiveUniformType(ActiveUniformType type)
646 case ActiveUniformType.Int:
647 case ActiveUniformType.Float:
648 case ActiveUniformType.Bool:
650 case ActiveUniformType.IntVec2:
651 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
652 case ActiveUniformType.UnsignedIntVec2:
654 case ActiveUniformType.FloatVec2:
655 case ActiveUniformType.BoolVec2:
657 case ActiveUniformType.IntVec3:
658 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
659 case ActiveUniformType.UnsignedIntVec3:
661 case ActiveUniformType.FloatVec3:
662 case ActiveUniformType.BoolVec3:
664 case ActiveUniformType.IntVec4:
665 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
666 case ActiveUniformType.UnsignedIntVec4:
668 case ActiveUniformType.FloatVec4:
669 case ActiveUniformType.BoolVec4:
670 case ActiveUniformType.FloatMat2:
672 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
673 case ActiveUniformType.FloatMat2x3:
674 case ActiveUniformType.FloatMat3x2:
676 case ActiveUniformType.FloatMat2x4:
677 case ActiveUniformType.FloatMat4x2:
680 case ActiveUniformType.FloatMat3:
682 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
683 case ActiveUniformType.FloatMat3x4:
684 case ActiveUniformType.FloatMat4x3:
687 case ActiveUniformType.FloatMat4:
690 case ActiveUniformType.Sampler2D:
691 case ActiveUniformType.SamplerCube:
692 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
693 case ActiveUniformType.Sampler1D:
694 case ActiveUniformType.Sampler3D:
695 case ActiveUniformType.Sampler1DShadow:
696 case ActiveUniformType.Sampler2DShadow:
697 case ActiveUniformType.Sampler2DRect:
698 case ActiveUniformType.Sampler2DRectShadow:
699 case ActiveUniformType.SamplerCubeShadow:
700 case ActiveUniformType.IntSampler1D:
701 case ActiveUniformType.IntSampler2D:
702 case ActiveUniformType.IntSampler3D:
703 case ActiveUniformType.IntSamplerCube:
704 case ActiveUniformType.IntSampler2DRect:
705 case ActiveUniformType.UnsignedIntSampler1D:
706 case ActiveUniformType.UnsignedIntSampler2D:
707 case ActiveUniformType.UnsignedIntSampler3D:
708 case ActiveUniformType.UnsignedIntSamplerCube:
709 case ActiveUniformType.UnsignedIntSampler2DRect:
711 case ActiveUniformType.Sampler1DArray:
712 case ActiveUniformType.Sampler2DArray:
713 case ActiveUniformType.Sampler1DArrayShadow:
714 case ActiveUniformType.Sampler2DArrayShadow:
715 case ActiveUniformType.IntSampler1DArray:
716 case ActiveUniformType.IntSampler2DArray:
717 case ActiveUniformType.UnsignedIntSampler1DArray:
718 case ActiveUniformType.UnsignedIntSampler2DArray:
720 case ActiveUniformType.SamplerBuffer:
721 case ActiveUniformType.IntSamplerBuffer:
722 case ActiveUniformType.UnsignedIntSamplerBuffer:
724 case ActiveUniformType.Sampler2DMultisample:
725 case ActiveUniformType.IntSampler2DMultisample:
726 case ActiveUniformType.UnsignedIntSampler2DMultisample:
728 case ActiveUniformType.Sampler2DMultisampleArray:
729 case ActiveUniformType.IntSampler2DMultisampleArray:
730 case ActiveUniformType.UnsignedIntSampler2DMultisampleArray:
743 case ActiveUniformType.Int:
744 case ActiveUniformType.Float:
745 case ActiveUniformType.Bool:
746 return EffectParameterClass.Scalar;
747 case ActiveUniformType.FloatVec2:
748 case ActiveUniformType.FloatVec3:
749 case ActiveUniformType.FloatVec4:
750 case ActiveUniformType.IntVec2:
751 case ActiveUniformType.IntVec3:
752 case ActiveUniformType.IntVec4:
753 case ActiveUniformType.BoolVec2:
754 case ActiveUniformType.BoolVec3:
755 case ActiveUniformType.BoolVec4:
756 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
757 case ActiveUniformType.UnsignedIntVec2:
758 case ActiveUniformType.UnsignedIntVec3:
759 case ActiveUniformType.UnsignedIntVec4:
761 return EffectParameterClass.Vector;
762 case ActiveUniformType.FloatMat2:
763 case ActiveUniformType.FloatMat3:
764 case ActiveUniformType.FloatMat4:
765 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
766 case ActiveUniformType.FloatMat2x3:
767 case ActiveUniformType.FloatMat2x4:
768 case ActiveUniformType.FloatMat3x2:
769 case ActiveUniformType.FloatMat3x4:
770 case ActiveUniformType.FloatMat4x2:
771 case ActiveUniformType.FloatMat4x3:
773 return EffectParameterClass.MatrixColumns;
776 case ActiveUniformType.Sampler2D:
777 case ActiveUniformType.SamplerCube:
778 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
779 case ActiveUniformType.Sampler1D:
780 case ActiveUniformType.Sampler3D:
781 case ActiveUniformType.Sampler1DShadow:
782 case ActiveUniformType.Sampler2DShadow:
783 case ActiveUniformType.Sampler2DRect:
784 case ActiveUniformType.Sampler2DRectShadow:
785 case ActiveUniformType.Sampler1DArray:
786 case ActiveUniformType.Sampler2DArray:
787 case ActiveUniformType.SamplerBuffer:
788 case ActiveUniformType.Sampler1DArrayShadow:
789 case ActiveUniformType.Sampler2DArrayShadow:
790 case ActiveUniformType.SamplerCubeShadow:
791 case ActiveUniformType.IntSampler1D:
792 case ActiveUniformType.IntSampler2D:
793 case ActiveUniformType.IntSampler3D:
794 case ActiveUniformType.IntSamplerCube:
795 case ActiveUniformType.IntSampler2DRect:
796 case ActiveUniformType.IntSampler1DArray:
797 case ActiveUniformType.IntSampler2DArray:
798 case ActiveUniformType.IntSamplerBuffer:
799 case ActiveUniformType.UnsignedIntSampler1D:
800 case ActiveUniformType.UnsignedIntSampler2D:
801 case ActiveUniformType.UnsignedIntSampler3D:
802 case ActiveUniformType.UnsignedIntSamplerCube:
803 case ActiveUniformType.UnsignedIntSampler2DRect:
804 case ActiveUniformType.UnsignedIntSampler1DArray:
805 case ActiveUniformType.UnsignedIntSampler2DArray:
806 case ActiveUniformType.UnsignedIntSamplerBuffer:
807 case ActiveUniformType.Sampler2DMultisample:
808 case ActiveUniformType.IntSampler2DMultisample:
809 case ActiveUniformType.UnsignedIntSampler2DMultisample:
810 case ActiveUniformType.Sampler2DMultisampleArray:
811 case ActiveUniformType.IntSampler2DMultisampleArray:
812 case ActiveUniformType.UnsignedIntSampler2DMultisampleArray:
814 return EffectParameterClass.TextureBuffer;
817 return EffectParameterClass.Object;
825 case ActiveUniformType.Int:
826 case ActiveUniformType.IntVec2:
827 case ActiveUniformType.IntVec3:
828 case ActiveUniformType.IntVec4:
829 return EffectParameterType.Int;
830 case ActiveUniformType.Float:
831 case ActiveUniformType.FloatVec2:
832 case ActiveUniformType.FloatVec3:
833 case ActiveUniformType.FloatVec4:
834 case ActiveUniformType.FloatMat2:
835 case ActiveUniformType.FloatMat3:
836 case ActiveUniformType.FloatMat4:
837 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
838 case ActiveUniformType.FloatMat2x3:
839 case ActiveUniformType.FloatMat2x4:
840 case ActiveUniformType.FloatMat3x2:
841 case ActiveUniformType.FloatMat3x4:
842 case ActiveUniformType.FloatMat4x2:
843 case ActiveUniformType.FloatMat4x3:
845 return EffectParameterType.Float;
846 case ActiveUniformType.Bool:
847 case ActiveUniformType.BoolVec2:
848 case ActiveUniformType.BoolVec3:
849 case ActiveUniformType.BoolVec4:
850 return EffectParameterType.Bool;
851 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
852 case ActiveUniformType.UnsignedIntVec2:
853 case ActiveUniformType.UnsignedIntVec3:
854 case ActiveUniformType.UnsignedIntVec4:
855 return EffectParameterType.UInt;
856 case ActiveUniformType.Sampler1D:
857 case ActiveUniformType.Sampler1DShadow:
858 case ActiveUniformType.IntSampler1D:
859 case ActiveUniformType.UnsignedIntSampler1D:
860 return EffectParameterType.Texture1D;
862 case ActiveUniformType.Sampler2D:
863 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
864 case ActiveUniformType.Sampler2DShadow:
865 case ActiveUniformType.Sampler2DRect:
866 case ActiveUniformType.Sampler2DRectShadow:
867 case ActiveUniformType.IntSampler2D:
868 case ActiveUniformType.IntSampler2DRect:
869 case ActiveUniformType.UnsignedIntSampler2D:
870 case ActiveUniformType.UnsignedIntSampler2DRect:
872 return EffectParameterType.Texture2D;
873 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
874 case ActiveUniformType.Sampler3D:
875 case ActiveUniformType.IntSampler3D:
876 case ActiveUniformType.UnsignedIntSampler3D:
877 return EffectParameterType.Texture3D;
879 case ActiveUniformType.SamplerCube:
880 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
881 case ActiveUniformType.SamplerCubeShadow:
882 case ActiveUniformType.IntSamplerCube:
883 case ActiveUniformType.UnsignedIntSamplerCube:
885 return EffectParameterType.TextureCube;
886 #if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
887 case ActiveUniformType.Sampler1DArray:
888 case ActiveUniformType.Sampler1DArrayShadow:
889 case ActiveUniformType.IntSampler1DArray:
890 case ActiveUniformType.UnsignedIntSampler1DArray:
891 return EffectParameterType.Texture1DArray;
892 case ActiveUniformType.Sampler2DArray:
893 case ActiveUniformType.Sampler2DArrayShadow:
894 case ActiveUniformType.IntSampler2DArray:
895 case ActiveUniformType.UnsignedIntSampler2DArray:
896 return EffectParameterType.Texture2DArray;
897 case ActiveUniformType.SamplerBuffer:
898 case ActiveUniformType.IntSamplerBuffer:
899 case ActiveUniformType.UnsignedIntSamplerBuffer:
900 return EffectParameterType.TextureBuffer;
901 case ActiveUniformType.Sampler2DMultisample:
902 case ActiveUniformType.IntSampler2DMultisample:
903 case ActiveUniformType.UnsignedIntSampler2DMultisample:
904 return EffectParameterType.Texture2DMultisampled;
905 case ActiveUniformType.Sampler2DMultisampleArray:
906 case ActiveUniformType.IntSampler2DMultisampleArray:
907 case ActiveUniformType.UnsignedIntSampler2DMultisampleArray:
908 return EffectParameterType.Texture2DMultisampledArray;
912 return EffectParameterType.Void;
916 class UniformMergeInfo
918 public ActiveUniformType
Type;
920 public int NextOffset;
SiliconStudio.Shaders.Ast.Hlsl.ConstantBuffer ConstantBuffer
The content is resized to fit in the destination dimensions while it preserves its native aspect rati...
ComponentBase.Destroy() event.
SiliconStudio.Core.Diagnostics.LoggerResult LoggerResult
The type of the serialized type will be passed as a generic arguments of the serializer. Example: serializer of A becomes instantiated as Serializer{A}.
Same as Deferred mode, except sprites are sorted by texture prior to drawing. This can improve perfor...
EffectParameterClass
Values that identify the class of a shader variable.
ShaderStage
Enum to specify shader stage.
_In_ size_t _In_ size_t size