Serenity Operating System
at master 98 lines 2.5 kB view raw
1/* 2 * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org> 3 * Copyright (c) 2022, Jelle Raaijmakers <jelle@gmta.nl> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <AK/Array.h> 11#include <LibGPU/Image.h> 12#include <LibGfx/Vector4.h> 13 14namespace GPU { 15 16enum class TextureFilter { 17 Nearest, 18 Linear, 19}; 20 21enum class MipMapFilter { 22 None, 23 Nearest, 24 Linear, 25}; 26 27enum class TextureWrapMode { 28 Repeat, 29 MirroredRepeat, 30 Clamp, 31 ClampToBorder, 32 ClampToEdge, 33}; 34 35enum class TextureEnvMode { 36 Add, 37 Blend, 38 Combine, 39 Decal, 40 Modulate, 41 Replace, 42}; 43 44enum class TextureCombinator { 45 Add, 46 AddSigned, 47 Dot3RGB, 48 Dot3RGBA, 49 Interpolate, 50 Modulate, 51 Replace, 52 Subtract, 53}; 54 55enum class TextureOperand { 56 OneMinusSourceAlpha, 57 OneMinusSourceColor, 58 SourceAlpha, 59 SourceColor, 60}; 61 62enum class TextureSource { 63 Constant, 64 Previous, 65 PrimaryColor, 66 Texture, 67 TextureStage, 68}; 69 70struct FixedFunctionTextureEnvironment final { 71 TextureCombinator alpha_combinator { TextureCombinator::Modulate }; 72 Array<TextureOperand, 3> alpha_operand { TextureOperand::SourceAlpha, TextureOperand::SourceAlpha, TextureOperand::SourceAlpha }; 73 float alpha_scale { 1.f }; 74 Array<TextureSource, 3> alpha_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant }; 75 u8 alpha_source_texture_stage { 0 }; 76 FloatVector4 color { 0.f, 0.f, 0.f, 0.f }; 77 TextureEnvMode env_mode { TextureEnvMode::Modulate }; 78 TextureCombinator rgb_combinator { TextureCombinator::Modulate }; 79 Array<TextureOperand, 3> rgb_operand { TextureOperand::SourceColor, TextureOperand::SourceColor, TextureOperand::SourceAlpha }; 80 float rgb_scale { 1.f }; 81 Array<TextureSource, 3> rgb_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant }; 82 u8 rgb_source_texture_stage { 0 }; 83}; 84 85struct SamplerConfig final { 86 RefPtr<Image> bound_image; 87 float level_of_detail_bias { 0.f }; 88 MipMapFilter mipmap_filter { MipMapFilter::Nearest }; 89 TextureFilter texture_mag_filter { TextureFilter::Linear }; 90 TextureFilter texture_min_filter { TextureFilter::Linear }; 91 TextureWrapMode texture_wrap_u { TextureWrapMode::Repeat }; 92 TextureWrapMode texture_wrap_v { TextureWrapMode::Repeat }; 93 TextureWrapMode texture_wrap_w { TextureWrapMode::Repeat }; 94 FloatVector4 border_color { 0.f, 0.f, 0.f, 1.f }; 95 FixedFunctionTextureEnvironment fixed_function_texture_environment {}; 96}; 97 98}