1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

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.
This commit is contained in:
Jelle Raaijmakers 2022-09-04 16:53:23 +02:00 committed by Linus Groh
parent 494024b70e
commit 1d36bfdac1
10 changed files with 461 additions and 58 deletions

View file

@ -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;

View file

@ -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 {};
};
}