summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGPU
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-09-04 16:53:23 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-11 22:37:07 +0100
commit1d36bfdac13332c8fc5272130bfb0dddf33cc91f (patch)
tree5198b8f3bbc3678454e92944141fe1595a027e94 /Userland/Libraries/LibGPU
parent494024b70e7bafc1a382f97645c8c9dbbdf2b0c4 (diff)
downloadserenity-1d36bfdac13332c8fc5272130bfb0dddf33cc91f.zip
LibGL+LibSoftGPU: Implement fixed pipeline support for `GL_COMBINE`
`GL_COMBINE` is basically a fixed function calculator to perform simple arithmetics on configurable fragment sources. This patch implements a number of texture env parameters with support for the RGBA internal format.
Diffstat (limited to 'Userland/Libraries/LibGPU')
-rw-r--r--Userland/Libraries/LibGPU/DeviceInfo.h1
-rw-r--r--Userland/Libraries/LibGPU/SamplerConfig.h53
2 files changed, 51 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGPU/DeviceInfo.h b/Userland/Libraries/LibGPU/DeviceInfo.h
index 3693bc820d..6e39a0001e 100644
--- a/Userland/Libraries/LibGPU/DeviceInfo.h
+++ b/Userland/Libraries/LibGPU/DeviceInfo.h
@@ -16,6 +16,7 @@ struct DeviceInfo final {
unsigned num_texture_units;
unsigned num_lights;
unsigned max_clip_planes;
+ float max_texture_lod_bias;
u8 stencil_bits;
bool supports_npot_textures;
bool supports_texture_env_add;
diff --git a/Userland/Libraries/LibGPU/SamplerConfig.h b/Userland/Libraries/LibGPU/SamplerConfig.h
index a4b5b140d6..898bdfb3b0 100644
--- a/Userland/Libraries/LibGPU/SamplerConfig.h
+++ b/Userland/Libraries/LibGPU/SamplerConfig.h
@@ -1,11 +1,13 @@
/*
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
+ * Copyright (c) 2022, Jelle Raaijmakers <jelle@gmta.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
+#include <AK/Array.h>
#include <LibGPU/Image.h>
#include <LibGfx/Vector4.h>
@@ -31,22 +33,67 @@ enum class TextureWrapMode {
};
enum class TextureEnvMode {
+ Add,
+ Blend,
+ Combine,
+ Decal,
Modulate,
Replace,
- Decal,
+};
+
+enum class TextureCombinator {
Add,
+ AddSigned,
+ Dot3RGB,
+ Dot3RGBA,
+ Interpolate,
+ Modulate,
+ Replace,
+ Subtract,
+};
+
+enum class TextureOperand {
+ OneMinusSourceAlpha,
+ OneMinusSourceColor,
+ SourceAlpha,
+ SourceColor,
+};
+
+enum class TextureSource {
+ Constant,
+ Previous,
+ PrimaryColor,
+ Texture,
+ TextureStage,
+};
+
+struct FixedFunctionTextureEnvironment final {
+ TextureCombinator alpha_combinator { TextureCombinator::Modulate };
+ Array<TextureOperand, 3> alpha_operand { TextureOperand::SourceAlpha, TextureOperand::SourceAlpha, TextureOperand::SourceAlpha };
+ float alpha_scale { 1.f };
+ Array<TextureSource, 3> alpha_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant };
+ u8 alpha_source_texture_stage { 0 };
+ // FIXME: color is never actually updated
+ FloatVector4 color { 0.f, 0.f, 0.f, 0.f };
+ TextureEnvMode env_mode { TextureEnvMode::Modulate };
+ TextureCombinator rgb_combinator { TextureCombinator::Modulate };
+ Array<TextureOperand, 3> rgb_operand { TextureOperand::SourceColor, TextureOperand::SourceColor, TextureOperand::SourceAlpha };
+ float rgb_scale { 1.f };
+ Array<TextureSource, 3> rgb_source { TextureSource::Texture, TextureSource::Previous, TextureSource::Constant };
+ u8 rgb_source_texture_stage { 0 };
};
struct SamplerConfig final {
RefPtr<Image> bound_image;
+ float level_of_detail_bias { 0.f };
MipMapFilter mipmap_filter { MipMapFilter::Nearest };
TextureFilter texture_mag_filter { TextureFilter::Linear };
TextureFilter texture_min_filter { TextureFilter::Linear };
TextureWrapMode texture_wrap_u { TextureWrapMode::Repeat };
TextureWrapMode texture_wrap_v { TextureWrapMode::Repeat };
TextureWrapMode texture_wrap_w { TextureWrapMode::Repeat };
- FloatVector4 border_color { 0, 0, 0, 1 };
- TextureEnvMode fixed_function_texture_env_mode { TextureEnvMode::Modulate };
+ FloatVector4 border_color { 0.f, 0.f, 0.f, 1.f };
+ FixedFunctionTextureEnvironment fixed_function_texture_environment {};
};
}