mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 20:25:07 +00:00

Between the OpenGL client and server, a lot of data type and color conversion needs to happen. We are performing these conversions both in `LibSoftGPU` and `LibGL`, which is not ideal. Additionally, some concepts like the color, depth and stencil buffers should share their logic but have separate implementations. This is the first step towards generalizing our `LibSoftGPU` frame buffer: a generalized `Typed3DBuffer` is introduced for arbitrary 3D value storage and retrieval, and `Typed2DBuffer` wraps around it to provide in an easy-to-use 2D pixel buffer. The color, depth and stencil buffers are replaced by `Typed2DBuffer` and are now managed by the new `FrameBuffer` class. The `Image` class now uses multiple `Typed3DBuffer`s for layers and mipmap levels. Additionally, the textures are now always stored as BGRA8888, only converting between formats when reading or writing pixels. Ideally this refactor should have no functional changes, but some graphical glitches in Grim Fandango seem to be fixed and most OpenGL ports get an FPS boost on my machine. :^)
135 lines
1.8 KiB
C++
135 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
|
|
namespace SoftGPU {
|
|
|
|
using ColorType = u32; // BGRA:8888
|
|
using DepthType = float;
|
|
using StencilType = u8;
|
|
|
|
enum class AlphaTestFunction {
|
|
Never,
|
|
Always,
|
|
Less,
|
|
LessOrEqual,
|
|
Equal,
|
|
NotEqual,
|
|
GreaterOrEqual,
|
|
Greater,
|
|
};
|
|
|
|
enum class BlendFactor {
|
|
Zero,
|
|
One,
|
|
SrcAlpha,
|
|
OneMinusSrcAlpha,
|
|
SrcColor,
|
|
OneMinusSrcColor,
|
|
DstAlpha,
|
|
OneMinusDstAlpha,
|
|
DstColor,
|
|
OneMinusDstColor,
|
|
SrcAlphaSaturate,
|
|
};
|
|
|
|
enum class ColorMaterialFace {
|
|
Front,
|
|
Back,
|
|
FrontAndBack,
|
|
};
|
|
|
|
enum class ColorMaterialMode {
|
|
Ambient,
|
|
AmbientAndDiffuse,
|
|
Diffuse,
|
|
Emissive,
|
|
Specular,
|
|
};
|
|
|
|
enum class DepthTestFunction {
|
|
Never,
|
|
Always,
|
|
Less,
|
|
LessOrEqual,
|
|
Equal,
|
|
NotEqual,
|
|
GreaterOrEqual,
|
|
Greater,
|
|
};
|
|
|
|
enum Face {
|
|
Front = 0,
|
|
Back = 1,
|
|
};
|
|
|
|
enum FogMode {
|
|
Linear,
|
|
Exp,
|
|
Exp2
|
|
};
|
|
|
|
enum class PolygonMode {
|
|
Point,
|
|
Line,
|
|
Fill,
|
|
};
|
|
|
|
enum class WindingOrder {
|
|
Clockwise,
|
|
CounterClockwise,
|
|
};
|
|
|
|
enum class PrimitiveType {
|
|
Triangles,
|
|
TriangleStrip,
|
|
TriangleFan,
|
|
Quads,
|
|
};
|
|
|
|
enum StencilOperation {
|
|
Decrement,
|
|
DecrementWrap,
|
|
Increment,
|
|
IncrementWrap,
|
|
Invert,
|
|
Keep,
|
|
Replace,
|
|
Zero,
|
|
};
|
|
|
|
enum StencilTestFunction {
|
|
Always,
|
|
Equal,
|
|
Greater,
|
|
GreaterOrEqual,
|
|
Less,
|
|
LessOrEqual,
|
|
Never,
|
|
NotEqual,
|
|
};
|
|
|
|
enum TexCoordGenerationCoordinate {
|
|
None = 0x0,
|
|
S = 0x1,
|
|
T = 0x2,
|
|
R = 0x4,
|
|
Q = 0x8,
|
|
All = 0xF,
|
|
};
|
|
|
|
enum class TexCoordGenerationMode {
|
|
ObjectLinear,
|
|
EyeLinear,
|
|
SphereMap,
|
|
ReflectionMap,
|
|
NormalMap,
|
|
};
|
|
|
|
}
|