SamplerConfig.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #pragma once
  8. #include <AK/Array.h>
  9. #include <LibGPU/Image.h>
  10. #include <LibGfx/Vector4.h>
  11. namespace GPU {
  12. enum class TextureFilter {
  13. Nearest,
  14. Linear,
  15. };
  16. enum class MipMapFilter {
  17. None,
  18. Nearest,
  19. Linear,
  20. };
  21. enum class TextureWrapMode {
  22. Repeat,
  23. MirroredRepeat,
  24. Clamp,
  25. ClampToBorder,
  26. ClampToEdge,
  27. };
  28. enum class TextureEnvMode {
  29. Add,
  30. Blend,
  31. Combine,
  32. Decal,
  33. Modulate,
  34. Replace,
  35. };
  36. enum class TextureCombinator {
  37. Add,
  38. AddSigned,
  39. Dot3RGB,
  40. Dot3RGBA,
  41. Interpolate,
  42. Modulate,
  43. Replace,
  44. Subtract,
  45. };
  46. enum class TextureOperand {
  47. OneMinusSourceAlpha,
  48. OneMinusSourceColor,
  49. SourceAlpha,
  50. SourceColor,
  51. };
  52. enum class TextureSource {
  53. Constant,
  54. Previous,
  55. PrimaryColor,
  56. Texture,
  57. TextureStage,
  58. };
  59. struct FixedFunctionTextureEnvironment final {
  60. TextureCombinator alpha_combinator { TextureCombinator::Modulate };
  61. Array<TextureOperand, 3> alpha_operand { TextureOperand::SourceAlpha, TextureOperand::SourceAlpha, TextureOperand::SourceAlpha };
  62. float alpha_scale { 1.f };
  63. Array<TextureSource, 3> alpha_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant };
  64. u8 alpha_source_texture_stage { 0 };
  65. FloatVector4 color { 0.f, 0.f, 0.f, 0.f };
  66. TextureEnvMode env_mode { TextureEnvMode::Modulate };
  67. TextureCombinator rgb_combinator { TextureCombinator::Modulate };
  68. Array<TextureOperand, 3> rgb_operand { TextureOperand::SourceColor, TextureOperand::SourceColor, TextureOperand::SourceAlpha };
  69. float rgb_scale { 1.f };
  70. Array<TextureSource, 3> rgb_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant };
  71. u8 rgb_source_texture_stage { 0 };
  72. };
  73. struct SamplerConfig final {
  74. RefPtr<Image> bound_image;
  75. float level_of_detail_bias { 0.f };
  76. MipMapFilter mipmap_filter { MipMapFilter::Nearest };
  77. TextureFilter texture_mag_filter { TextureFilter::Linear };
  78. TextureFilter texture_min_filter { TextureFilter::Linear };
  79. TextureWrapMode texture_wrap_u { TextureWrapMode::Repeat };
  80. TextureWrapMode texture_wrap_v { TextureWrapMode::Repeat };
  81. TextureWrapMode texture_wrap_w { TextureWrapMode::Repeat };
  82. FloatVector4 border_color { 0.f, 0.f, 0.f, 1.f };
  83. FixedFunctionTextureEnvironment fixed_function_texture_environment {};
  84. };
  85. }