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

LibGL+LibGPU+LibSoftGPU: Move Enums.h to LibGPU

This commit is contained in:
Stephan Unverwerth 2022-03-15 01:11:58 +01:00 committed by Andreas Kling
parent ac033dd9b6
commit 24d420312c
6 changed files with 198 additions and 197 deletions

View file

@ -23,4 +23,8 @@ static constexpr int NUM_LIGHTS = 8;
// FIXME: make this dynamically configurable through ConfigServer
static constexpr bool CLAMP_DEPRECATED_BEHAVIOR = false;
using ColorType = u32; // BGRA:8888
using DepthType = float;
using StencilType = u8;
}

View file

@ -97,79 +97,79 @@ void Device::setup_blend_factors()
m_alpha_blend_factors = {};
switch (m_options.blend_source_factor) {
case BlendFactor::Zero:
case GPU::BlendFactor::Zero:
break;
case BlendFactor::One:
case GPU::BlendFactor::One:
m_alpha_blend_factors.src_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
break;
case BlendFactor::SrcColor:
case GPU::BlendFactor::SrcColor:
m_alpha_blend_factors.src_factor_src_color = 1;
break;
case BlendFactor::OneMinusSrcColor:
case GPU::BlendFactor::OneMinusSrcColor:
m_alpha_blend_factors.src_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.src_factor_src_color = -1;
break;
case BlendFactor::SrcAlpha:
case GPU::BlendFactor::SrcAlpha:
m_alpha_blend_factors.src_factor_src_alpha = 1;
break;
case BlendFactor::OneMinusSrcAlpha:
case GPU::BlendFactor::OneMinusSrcAlpha:
m_alpha_blend_factors.src_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.src_factor_src_alpha = -1;
break;
case BlendFactor::DstAlpha:
case GPU::BlendFactor::DstAlpha:
m_alpha_blend_factors.src_factor_dst_alpha = 1;
break;
case BlendFactor::OneMinusDstAlpha:
case GPU::BlendFactor::OneMinusDstAlpha:
m_alpha_blend_factors.src_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.src_factor_dst_alpha = -1;
break;
case BlendFactor::DstColor:
case GPU::BlendFactor::DstColor:
m_alpha_blend_factors.src_factor_dst_color = 1;
break;
case BlendFactor::OneMinusDstColor:
case GPU::BlendFactor::OneMinusDstColor:
m_alpha_blend_factors.src_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.src_factor_dst_color = -1;
break;
case BlendFactor::SrcAlphaSaturate:
case GPU::BlendFactor::SrcAlphaSaturate:
default:
VERIFY_NOT_REACHED();
}
switch (m_options.blend_destination_factor) {
case BlendFactor::Zero:
case GPU::BlendFactor::Zero:
break;
case BlendFactor::One:
case GPU::BlendFactor::One:
m_alpha_blend_factors.dst_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
break;
case BlendFactor::SrcColor:
case GPU::BlendFactor::SrcColor:
m_alpha_blend_factors.dst_factor_src_color = 1;
break;
case BlendFactor::OneMinusSrcColor:
case GPU::BlendFactor::OneMinusSrcColor:
m_alpha_blend_factors.dst_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.dst_factor_src_color = -1;
break;
case BlendFactor::SrcAlpha:
case GPU::BlendFactor::SrcAlpha:
m_alpha_blend_factors.dst_factor_src_alpha = 1;
break;
case BlendFactor::OneMinusSrcAlpha:
case GPU::BlendFactor::OneMinusSrcAlpha:
m_alpha_blend_factors.dst_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.dst_factor_src_alpha = -1;
break;
case BlendFactor::DstAlpha:
case GPU::BlendFactor::DstAlpha:
m_alpha_blend_factors.dst_factor_dst_alpha = 1;
break;
case BlendFactor::OneMinusDstAlpha:
case GPU::BlendFactor::OneMinusDstAlpha:
m_alpha_blend_factors.dst_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.dst_factor_dst_alpha = -1;
break;
case BlendFactor::DstColor:
case GPU::BlendFactor::DstColor:
m_alpha_blend_factors.dst_factor_dst_color = 1;
break;
case BlendFactor::OneMinusDstColor:
case GPU::BlendFactor::OneMinusDstColor:
m_alpha_blend_factors.dst_constant = { 1.0f, 1.0f, 1.0f, 1.0f };
m_alpha_blend_factors.dst_factor_dst_color = -1;
break;
case BlendFactor::SrcAlphaSaturate:
case GPU::BlendFactor::SrcAlphaSaturate:
default:
VERIFY_NOT_REACHED();
}
@ -180,7 +180,7 @@ void Device::rasterize_triangle(Triangle const& triangle)
INCREASE_STATISTICS_COUNTER(g_num_rasterized_triangles, 1);
// Return if alpha testing is a no-op
if (m_options.enable_alpha_test && m_options.alpha_test_func == AlphaTestFunction::Never)
if (m_options.enable_alpha_test && m_options.alpha_test_func == GPU::AlphaTestFunction::Never)
return;
// Vertices
@ -262,33 +262,33 @@ void Device::rasterize_triangle(Triangle const& triangle)
auto stencil_buffer = m_frame_buffer->stencil_buffer();
// Stencil configuration and writing
auto const& stencil_configuration = m_stencil_configuration[Face::Front];
auto const& stencil_configuration = m_stencil_configuration[GPU::Face::Front];
auto const stencil_reference_value = stencil_configuration.reference_value & stencil_configuration.test_mask;
auto write_to_stencil = [](StencilType* stencil_ptrs[4], i32x4 stencil_value, StencilOperation op, StencilType reference_value, StencilType write_mask, i32x4 pixel_mask) {
if (write_mask == 0 || op == StencilOperation::Keep)
auto write_to_stencil = [](StencilType* stencil_ptrs[4], i32x4 stencil_value, GPU::StencilOperation op, StencilType reference_value, StencilType write_mask, i32x4 pixel_mask) {
if (write_mask == 0 || op == GPU::StencilOperation::Keep)
return;
switch (op) {
case StencilOperation::Decrement:
case GPU::StencilOperation::Decrement:
stencil_value = (stencil_value & ~write_mask) | (max(stencil_value - 1, expand4(0)) & write_mask);
break;
case StencilOperation::DecrementWrap:
case GPU::StencilOperation::DecrementWrap:
stencil_value = (stencil_value & ~write_mask) | (((stencil_value - 1) & 0xFF) & write_mask);
break;
case StencilOperation::Increment:
case GPU::StencilOperation::Increment:
stencil_value = (stencil_value & ~write_mask) | (min(stencil_value + 1, expand4(0xFF)) & write_mask);
break;
case StencilOperation::IncrementWrap:
case GPU::StencilOperation::IncrementWrap:
stencil_value = (stencil_value & ~write_mask) | (((stencil_value + 1) & 0xFF) & write_mask);
break;
case StencilOperation::Invert:
case GPU::StencilOperation::Invert:
stencil_value ^= write_mask;
break;
case StencilOperation::Replace:
case GPU::StencilOperation::Replace:
stencil_value = (stencil_value & ~write_mask) | (reference_value & write_mask);
break;
case StencilOperation::Zero:
case GPU::StencilOperation::Zero:
stencil_value &= ~write_mask;
break;
default:
@ -344,28 +344,28 @@ void Device::rasterize_triangle(Triangle const& triangle)
i32x4 stencil_test_passed;
switch (stencil_configuration.test_function) {
case StencilTestFunction::Always:
case GPU::StencilTestFunction::Always:
stencil_test_passed = expand4(~0);
break;
case StencilTestFunction::Equal:
case GPU::StencilTestFunction::Equal:
stencil_test_passed = stencil_value == stencil_reference_value;
break;
case StencilTestFunction::Greater:
case GPU::StencilTestFunction::Greater:
stencil_test_passed = stencil_value > stencil_reference_value;
break;
case StencilTestFunction::GreaterOrEqual:
case GPU::StencilTestFunction::GreaterOrEqual:
stencil_test_passed = stencil_value >= stencil_reference_value;
break;
case StencilTestFunction::Less:
case GPU::StencilTestFunction::Less:
stencil_test_passed = stencil_value < stencil_reference_value;
break;
case StencilTestFunction::LessOrEqual:
case GPU::StencilTestFunction::LessOrEqual:
stencil_test_passed = stencil_value <= stencil_reference_value;
break;
case StencilTestFunction::Never:
case GPU::StencilTestFunction::Never:
stencil_test_passed = expand4(0);
break;
case StencilTestFunction::NotEqual:
case GPU::StencilTestFunction::NotEqual:
stencil_test_passed = stencil_value != stencil_reference_value;
break;
default:
@ -407,19 +407,19 @@ void Device::rasterize_triangle(Triangle const& triangle)
i32x4 depth_test_passed;
switch (m_options.depth_func) {
case DepthTestFunction::Always:
case GPU::DepthTestFunction::Always:
depth_test_passed = expand4(~0);
break;
case DepthTestFunction::Never:
case GPU::DepthTestFunction::Never:
depth_test_passed = expand4(0);
break;
case DepthTestFunction::Greater:
case GPU::DepthTestFunction::Greater:
depth_test_passed = quad.depth > depth;
break;
case DepthTestFunction::GreaterOrEqual:
case GPU::DepthTestFunction::GreaterOrEqual:
depth_test_passed = quad.depth >= depth;
break;
case DepthTestFunction::NotEqual:
case GPU::DepthTestFunction::NotEqual:
#ifdef __SSE__
depth_test_passed = quad.depth != depth;
#else
@ -431,7 +431,7 @@ void Device::rasterize_triangle(Triangle const& triangle)
};
#endif
break;
case DepthTestFunction::Equal:
case GPU::DepthTestFunction::Equal:
#ifdef __SSE__
depth_test_passed = quad.depth == depth;
#else
@ -454,10 +454,10 @@ void Device::rasterize_triangle(Triangle const& triangle)
};
#endif
break;
case DepthTestFunction::LessOrEqual:
case GPU::DepthTestFunction::LessOrEqual:
depth_test_passed = quad.depth <= depth;
break;
case DepthTestFunction::Less:
case GPU::DepthTestFunction::Less:
depth_test_passed = quad.depth < depth;
break;
default:
@ -518,7 +518,7 @@ void Device::rasterize_triangle(Triangle const& triangle)
shade_fragments(quad);
if (m_options.enable_alpha_test && m_options.alpha_test_func != AlphaTestFunction::Always && !test_alpha(quad))
if (m_options.enable_alpha_test && m_options.alpha_test_func != GPU::AlphaTestFunction::Always && !test_alpha(quad))
continue;
// Write to depth buffer
@ -595,15 +595,15 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
auto mode = options.texcoord_generation_config[texcoord_index][config_index].mode;
switch (mode) {
case TexCoordGenerationMode::ObjectLinear: {
case GPU::TexCoordGenerationMode::ObjectLinear: {
auto coefficients = options.texcoord_generation_config[texcoord_index][config_index].coefficients;
return coefficients.dot(vertex.position);
}
case TexCoordGenerationMode::EyeLinear: {
case GPU::TexCoordGenerationMode::EyeLinear: {
auto coefficients = options.texcoord_generation_config[texcoord_index][config_index].coefficients;
return coefficients.dot(vertex.eye_coordinates);
}
case TexCoordGenerationMode::SphereMap: {
case GPU::TexCoordGenerationMode::SphereMap: {
auto const eye_unit = vertex.eye_coordinates.normalized();
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
auto const normal = vertex.normal;
@ -612,14 +612,14 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
auto const reflection_value = reflection[config_index];
return reflection_value / (2 * reflection.length()) + 0.5f;
}
case TexCoordGenerationMode::ReflectionMap: {
case GPU::TexCoordGenerationMode::ReflectionMap: {
auto const eye_unit = vertex.eye_coordinates.normalized();
FloatVector3 const eye_unit_xyz = eye_unit.xyz();
auto const normal = vertex.normal;
auto reflection = eye_unit_xyz - normal * 2 * normal.dot(eye_unit_xyz);
return reflection[config_index];
}
case TexCoordGenerationMode::NormalMap: {
case GPU::TexCoordGenerationMode::NormalMap: {
return vertex.normal[config_index];
}
default:
@ -631,15 +631,15 @@ static void generate_texture_coordinates(Vertex& vertex, RasterizerOptions const
auto& tex_coord = vertex.tex_coords[i];
auto const enabled_coords = options.texcoord_generation_enabled_coordinates[i];
tex_coord = {
((enabled_coords & TexCoordGenerationCoordinate::S) > 0) ? generate_coordinate(i, 0) : tex_coord.x(),
((enabled_coords & TexCoordGenerationCoordinate::T) > 0) ? generate_coordinate(i, 1) : tex_coord.y(),
((enabled_coords & TexCoordGenerationCoordinate::R) > 0) ? generate_coordinate(i, 2) : tex_coord.z(),
((enabled_coords & TexCoordGenerationCoordinate::Q) > 0) ? generate_coordinate(i, 3) : tex_coord.w(),
((enabled_coords & GPU::TexCoordGenerationCoordinate::S) > 0) ? generate_coordinate(i, 0) : tex_coord.x(),
((enabled_coords & GPU::TexCoordGenerationCoordinate::T) > 0) ? generate_coordinate(i, 1) : tex_coord.y(),
((enabled_coords & GPU::TexCoordGenerationCoordinate::R) > 0) ? generate_coordinate(i, 2) : tex_coord.z(),
((enabled_coords & GPU::TexCoordGenerationCoordinate::Q) > 0) ? generate_coordinate(i, 3) : tex_coord.w(),
};
}
}
void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform,
void Device::draw_primitives(GPU::PrimitiveType primitive_type, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform,
FloatMatrix4x4 const& texture_transform, Vector<Vertex> const& vertices, Vector<size_t> const& enabled_texture_units)
{
// At this point, the user has effectively specified that they are done with defining the geometry
@ -658,7 +658,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
m_processed_triangles.clear_with_capacity();
// Let's construct some triangles
if (primitive_type == PrimitiveType::Triangles) {
if (primitive_type == GPU::PrimitiveType::Triangles) {
Triangle triangle;
if (vertices.size() < 3)
return;
@ -669,7 +669,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
m_triangle_list.append(triangle);
}
} else if (primitive_type == PrimitiveType::Quads) {
} else if (primitive_type == GPU::PrimitiveType::Quads) {
// We need to construct two triangles to form the quad
Triangle triangle;
if (vertices.size() < 4)
@ -687,7 +687,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
triangle.vertices[2] = vertices.at(i);
m_triangle_list.append(triangle);
}
} else if (primitive_type == PrimitiveType::TriangleFan) {
} else if (primitive_type == GPU::PrimitiveType::TriangleFan) {
Triangle triangle;
triangle.vertices[0] = vertices.at(0); // Root vertex is always the vertex defined first
@ -697,7 +697,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
triangle.vertices[2] = vertices.at(i + 1);
m_triangle_list.append(triangle);
}
} else if (primitive_type == PrimitiveType::TriangleStrip) {
} else if (primitive_type == GPU::PrimitiveType::TriangleStrip) {
Triangle triangle;
if (vertices.size() < 3)
return;
@ -753,22 +753,22 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
auto specular = material.specular;
if (m_options.color_material_enabled
&& (m_options.color_material_face == ColorMaterialFace::Front || m_options.color_material_face == ColorMaterialFace::FrontAndBack)) {
&& (m_options.color_material_face == GPU::ColorMaterialFace::Front || m_options.color_material_face == GPU::ColorMaterialFace::FrontAndBack)) {
switch (m_options.color_material_mode) {
case ColorMaterialMode::Ambient:
case GPU::ColorMaterialMode::Ambient:
ambient = vertex.color;
break;
case ColorMaterialMode::AmbientAndDiffuse:
case GPU::ColorMaterialMode::AmbientAndDiffuse:
ambient = vertex.color;
diffuse = vertex.color;
break;
case ColorMaterialMode::Diffuse:
case GPU::ColorMaterialMode::Diffuse:
diffuse = vertex.color;
break;
case ColorMaterialMode::Emissive:
case GPU::ColorMaterialMode::Emissive:
emissive = vertex.color;
break;
case ColorMaterialMode::Specular:
case GPU::ColorMaterialMode::Specular:
specular = vertex.color;
break;
}
@ -916,7 +916,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
// Generate texture coordinates if at least one coordinate is enabled
bool texture_coordinate_generation_enabled = false;
for (auto const coordinates_enabled : m_options.texcoord_generation_enabled_coordinates) {
if (coordinates_enabled != TexCoordGenerationCoordinate::None) {
if (coordinates_enabled != GPU::TexCoordGenerationCoordinate::None) {
texture_coordinate_generation_enabled = true;
break;
}
@ -935,7 +935,7 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
continue;
if (m_options.enable_culling) {
bool is_front = (m_options.front_face == WindingOrder::CounterClockwise ? area > 0 : area < 0);
bool is_front = (m_options.front_face == GPU::WindingOrder::CounterClockwise ? area > 0 : area < 0);
if (!is_front && m_options.cull_back)
continue;
@ -977,13 +977,13 @@ ALWAYS_INLINE void Device::shade_fragments(PixelQuad& quad)
// FIXME: Implement more blend modes
switch (sampler.config().fixed_function_texture_env_mode) {
case TextureEnvMode::Modulate:
case SoftGPU::TextureEnvMode::Modulate:
quad.out_color = quad.out_color * texel;
break;
case TextureEnvMode::Replace:
case SoftGPU::TextureEnvMode::Replace:
quad.out_color = texel;
break;
case TextureEnvMode::Decal: {
case SoftGPU::TextureEnvMode::Decal: {
auto dst_alpha = texel.w();
quad.out_color.set_x(mix(quad.out_color.x(), texel.x(), dst_alpha));
quad.out_color.set_y(mix(quad.out_color.y(), texel.y(), dst_alpha));
@ -1002,14 +1002,14 @@ ALWAYS_INLINE void Device::shade_fragments(PixelQuad& quad)
if (m_options.fog_enabled) {
auto factor = expand4(0.0f);
switch (m_options.fog_mode) {
case FogMode::Linear:
case GPU::FogMode::Linear:
factor = (m_options.fog_end - quad.fog_depth) / (m_options.fog_end - m_options.fog_start);
break;
case FogMode::Exp: {
case GPU::FogMode::Exp: {
auto argument = -m_options.fog_density * quad.fog_depth;
factor = exp(argument);
} break;
case FogMode::Exp2: {
case GPU::FogMode::Exp2: {
auto argument = m_options.fog_density * quad.fog_depth;
argument *= -argument;
factor = exp(argument);
@ -1032,26 +1032,26 @@ ALWAYS_INLINE bool Device::test_alpha(PixelQuad& quad)
auto const ref_value = expand4(m_options.alpha_test_ref_value);
switch (m_options.alpha_test_func) {
case AlphaTestFunction::Less:
case GPU::AlphaTestFunction::Less:
quad.mask &= alpha < ref_value;
break;
case AlphaTestFunction::Equal:
case GPU::AlphaTestFunction::Equal:
quad.mask &= alpha == ref_value;
break;
case AlphaTestFunction::LessOrEqual:
case GPU::AlphaTestFunction::LessOrEqual:
quad.mask &= alpha <= ref_value;
break;
case AlphaTestFunction::Greater:
case GPU::AlphaTestFunction::Greater:
quad.mask &= alpha > ref_value;
break;
case AlphaTestFunction::NotEqual:
case GPU::AlphaTestFunction::NotEqual:
quad.mask &= alpha != ref_value;
break;
case AlphaTestFunction::GreaterOrEqual:
case GPU::AlphaTestFunction::GreaterOrEqual:
quad.mask &= alpha >= ref_value;
break;
case AlphaTestFunction::Never:
case AlphaTestFunction::Always:
case GPU::AlphaTestFunction::Never:
case GPU::AlphaTestFunction::Always:
default:
VERIFY_NOT_REACHED();
}
@ -1241,12 +1241,12 @@ void Device::set_light_state(unsigned int light_id, Light const& light)
m_lights.at(light_id) = light;
}
void Device::set_material_state(Face face, Material const& material)
void Device::set_material_state(GPU::Face face, Material const& material)
{
m_materials[face] = material;
}
void Device::set_stencil_configuration(Face face, StencilConfiguration const& stencil_configuration)
void Device::set_stencil_configuration(GPU::Face face, StencilConfiguration const& stencil_configuration)
{
m_stencil_configuration[face] = stencil_configuration;
}

View file

@ -12,6 +12,7 @@
#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <LibGPU/DeviceInfo.h>
#include <LibGPU/Enums.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Matrix3x3.h>
#include <LibGfx/Matrix4x4.h>
@ -22,7 +23,6 @@
#include <LibSoftGPU/Buffer/Typed2DBuffer.h>
#include <LibSoftGPU/Clipper.h>
#include <LibSoftGPU/Config.h>
#include <LibSoftGPU/Enums.h>
#include <LibSoftGPU/Image.h>
#include <LibSoftGPU/ImageFormat.h>
#include <LibSoftGPU/Light/Light.h>
@ -34,7 +34,7 @@
namespace SoftGPU {
struct TexCoordGenerationConfig {
TexCoordGenerationMode mode { TexCoordGenerationMode::EyeLinear };
GPU::TexCoordGenerationMode mode { GPU::TexCoordGenerationMode::EyeLinear };
FloatVector4 coefficients {};
};
@ -44,19 +44,19 @@ struct RasterizerOptions {
bool enable_depth_test { false };
bool enable_depth_write { true };
bool enable_alpha_test { false };
AlphaTestFunction alpha_test_func { AlphaTestFunction::Always };
GPU::AlphaTestFunction alpha_test_func { GPU::AlphaTestFunction::Always };
float alpha_test_ref_value { 0 };
bool enable_blending { false };
BlendFactor blend_source_factor { BlendFactor::One };
BlendFactor blend_destination_factor { BlendFactor::One };
GPU::BlendFactor blend_source_factor { GPU::BlendFactor::One };
GPU::BlendFactor blend_destination_factor { GPU::BlendFactor::One };
u32 color_mask { 0xffffffff };
float depth_min { 0.f };
float depth_max { 1.f };
DepthTestFunction depth_func { DepthTestFunction::Less };
PolygonMode polygon_mode { PolygonMode::Fill };
GPU::DepthTestFunction depth_func { GPU::DepthTestFunction::Less };
GPU::PolygonMode polygon_mode { GPU::PolygonMode::Fill };
FloatVector4 fog_color { 0.0f, 0.0f, 0.0f, 0.0f };
float fog_density { 1.0f };
FogMode fog_mode { FogMode::Exp };
GPU::FogMode fog_mode { GPU::FogMode::Exp };
bool fog_enabled { false };
float fog_start { 0.0f };
float fog_end { 1.0f };
@ -68,7 +68,7 @@ struct RasterizerOptions {
float depth_offset_constant { 0 };
bool depth_offset_enabled { false };
bool enable_culling { false };
WindingOrder front_face { WindingOrder::CounterClockwise };
GPU::WindingOrder front_face { GPU::WindingOrder::CounterClockwise };
bool cull_back { true };
bool cull_front { false };
Array<u8, NUM_SAMPLERS> texcoord_generation_enabled_coordinates {};
@ -76,14 +76,14 @@ struct RasterizerOptions {
Gfx::IntRect viewport;
bool lighting_enabled { false };
bool color_material_enabled { false };
ColorMaterialFace color_material_face { ColorMaterialFace::FrontAndBack };
ColorMaterialMode color_material_mode { ColorMaterialMode::AmbientAndDiffuse };
GPU::ColorMaterialFace color_material_face { GPU::ColorMaterialFace::FrontAndBack };
GPU::ColorMaterialMode color_material_mode { GPU::ColorMaterialMode::AmbientAndDiffuse };
};
struct LightModelParameters {
FloatVector4 scene_ambient_color { 0.2f, 0.2f, 0.2f, 1.0f };
bool viewer_at_infinity { false };
ColorControl color_control { ColorControl::SingleColor };
GPU::ColorControl color_control { GPU::ColorControl::SingleColor };
bool two_sided_lighting { false };
};
@ -99,13 +99,13 @@ struct RasterPosition {
};
struct StencilConfiguration {
StencilTestFunction test_function;
GPU::StencilTestFunction test_function;
StencilType reference_value;
StencilType test_mask;
StencilOperation on_stencil_test_fail;
StencilOperation on_depth_test_fail;
StencilOperation on_pass;
GPU::StencilOperation on_stencil_test_fail;
GPU::StencilOperation on_depth_test_fail;
GPU::StencilOperation on_pass;
StencilType write_mask;
};
@ -115,7 +115,7 @@ public:
GPU::DeviceInfo info() const;
void draw_primitives(PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, FloatMatrix4x4 const& texture_transform, Vector<Vertex> const& vertices, Vector<size_t> const& enabled_texture_units);
void draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, FloatMatrix4x4 const& texture_transform, Vector<Vertex> const& vertices, Vector<size_t> const& enabled_texture_units);
void resize(Gfx::IntSize const& min_size);
void clear_color(FloatVector4 const&);
void clear_depth(DepthType);
@ -134,8 +134,8 @@ public:
void set_sampler_config(unsigned, SamplerConfig const&);
void set_light_state(unsigned, Light const&);
void set_material_state(Face, Material const&);
void set_stencil_configuration(Face, StencilConfiguration const&);
void set_material_state(GPU::Face, Material const&);
void set_stencil_configuration(GPU::Face, StencilConfiguration const&);
RasterPosition raster_position() const { return m_raster_position; }
void set_raster_position(RasterPosition const& raster_position);

View file

@ -1,140 +0,0 @@
/*
* 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 ColorControl {
SingleColor,
SeparateSpecularColor,
};
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,
};
}

View file

@ -10,10 +10,11 @@
#include <AK/FixedArray.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <LibGPU/Enums.h>
#include <LibGfx/Vector3.h>
#include <LibGfx/Vector4.h>
#include <LibSoftGPU/Buffer/Typed3DBuffer.h>
#include <LibSoftGPU/Enums.h>
#include <LibSoftGPU/Config.h>
#include <LibSoftGPU/ImageDataLayout.h>
#include <LibSoftGPU/ImageFormat.h>