/// <summary> /// Prepare the shader specialization state for quick binding lookups. /// </summary> /// <param name="stages">The shader stages</param> public void Prepare(CachedShaderStage[] stages) { _allTextures = _textureSpecialization.ToArray(); _textureByBinding = new Box <TextureSpecializationState> [stages.Length][]; _imageByBinding = new Box <TextureSpecializationState> [stages.Length][]; for (int i = 0; i < stages.Length; i++) { CachedShaderStage stage = stages[i]; if (stage?.Info != null) { var textures = stage.Info.Textures; var images = stage.Info.Images; var texBindings = new Box <TextureSpecializationState> [textures.Count]; var imageBindings = new Box <TextureSpecializationState> [images.Count]; int stageIndex = Math.Max(i - 1, 0); // Don't count VertexA for looking up spec state. No-Op for compute. for (int j = 0; j < textures.Count; j++) { var texture = textures[j]; texBindings[j] = GetTextureSpecState(stageIndex, texture.HandleIndex, texture.CbufSlot); } for (int j = 0; j < images.Count; j++) { var image = images[j]; imageBindings[j] = GetTextureSpecState(stageIndex, image.HandleIndex, image.CbufSlot); } _textureByBinding[i] = texBindings; _imageByBinding[i] = imageBindings; } } }
public TranslatedShaderVertexPair(CachedShaderStage vertexA, CachedShaderStage vertexB, ShaderProgram program) { VertexA = vertexA; VertexB = vertexB; Program = program; }
public TranslatedShader(CachedShaderStage shader, ShaderProgram program) { Shader = shader; Program = program; }