mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Enable GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
This commit is contained in:
@@ -67,7 +67,11 @@ target_include_directories(${LIBMANUL_NAME} PRIVATE
|
||||
|
||||
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
|
||||
GLM_ENABLE_EXPERIMENTAL
|
||||
GLM_FORCE_SWIZZLE)
|
||||
GLM_FORCE_SWIZZLE
|
||||
GLM_FORCE_CTOR_INIT
|
||||
GLM_FORCE_INLINE
|
||||
GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
|
||||
GLM_FORCE_INTRINSICS)
|
||||
|
||||
target_compile_definitions(${LIBMANUL_NAME} PRIVATE
|
||||
_USE_MATH_DEFINES)
|
||||
@@ -99,12 +103,13 @@ else ()
|
||||
target_compile_definitions(${LIBMANUL_NAME} PUBLIC "LIBMANUL_WITH_VULKAN=0")
|
||||
endif ()
|
||||
|
||||
## For double-precision vector goodness
|
||||
#if (WIN32)
|
||||
# target_compile_options(${LIBMANUL_NAME} PRIVATE "/arch:AVX2")
|
||||
#elseif (UNIX)
|
||||
# target_compile_options(${LIBMANUL_NAME} PRIVATE "-mavx2")
|
||||
#endif ()
|
||||
if(ENABLE_AVX2)
|
||||
if (WIN32)
|
||||
target_compile_options(${LIBMANUL_NAME} PRIVATE "/arch:AVX2")
|
||||
elseif (UNIX)
|
||||
target_compile_options(${LIBMANUL_NAME} PRIVATE "-mavx2")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
target_sources(${LIBMANUL_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/eu07_source/register.cpp")
|
||||
set_target_properties(nvrhi yaml-cpp fmt EnTT glfw yaml-cpp-parse yaml-cpp-read yaml-cpp-sandbox PROPERTIES FOLDER "libraries")
|
||||
|
||||
21
gl/ubo.h
21
gl/ubo.h
@@ -3,9 +3,18 @@
|
||||
#include "object.h"
|
||||
#include "bindable.h"
|
||||
#include "buffer.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#define UBS_PAD(x) uint8_t PAD[x]
|
||||
|
||||
// 12-byte vec3 for structs that must match an exact binary layout (UBOs, vertex data).
|
||||
// Stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES.
|
||||
// Guard prevents redefinition when stdafx.h also defines it.
|
||||
#ifndef PACKED_VEC3_DEFINED
|
||||
#define PACKED_VEC3_DEFINED
|
||||
using packed_vec3 = glm::vec<3, float, glm::packed_highp>;
|
||||
#endif
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class ubo : public buffer
|
||||
@@ -43,7 +52,7 @@ namespace gl
|
||||
glm::mat4 projection;
|
||||
glm::mat4 inv_view;
|
||||
glm::mat4 lightview[MAX_CASCADES];
|
||||
glm::vec3 cascade_end;
|
||||
packed_vec3 cascade_end;
|
||||
float time;
|
||||
glm::vec4 rain_params;
|
||||
glm::vec4 wiper_pos;
|
||||
@@ -88,13 +97,13 @@ namespace gl
|
||||
HEADLIGHTS
|
||||
};
|
||||
|
||||
glm::vec3 pos;
|
||||
packed_vec3 pos;
|
||||
type_e type;
|
||||
|
||||
glm::vec3 dir;
|
||||
packed_vec3 dir;
|
||||
float in_cutoff;
|
||||
|
||||
glm::vec3 color;
|
||||
packed_vec3 color;
|
||||
float out_cutoff;
|
||||
|
||||
float linear;
|
||||
@@ -113,10 +122,10 @@ namespace gl
|
||||
|
||||
struct light_ubs
|
||||
{
|
||||
glm::vec3 ambient;
|
||||
packed_vec3 ambient;
|
||||
UBS_PAD(4);
|
||||
|
||||
glm::vec3 fog_color;
|
||||
packed_vec3 fog_color;
|
||||
uint32_t lights_count;
|
||||
|
||||
light_element_ubs lights[MAX_LIGHTS];
|
||||
|
||||
@@ -3101,7 +3101,7 @@ bool opengl33_renderer::Render_cab(TDynamicObject const *Dynamic, float const Li
|
||||
auto const luminance { Global.fLuminance * ( Dynamic->fShade > 0.0f ? Dynamic->fShade : 1.0f ) };
|
||||
if( Lightlevel > 0.f ) {
|
||||
// crude way to light the cabin, until we have something more complete in place
|
||||
light_ubs.ambient += ( Dynamic->InteriorLight * Lightlevel ) * std::clamp( 1.25f - (float)luminance, 0.f, 1.f );
|
||||
light_ubs.ambient += packed_vec3( ( Dynamic->InteriorLight * Lightlevel ) * std::clamp( 1.25f - (float)luminance, 0.f, 1.f ) );
|
||||
light_ubo->update( light_ubs );
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ operator!=( lighting_data const &Left, lighting_data const &Right ) {
|
||||
namespace scene {
|
||||
|
||||
struct bounding_area {
|
||||
glm::highp_dvec3 center; // mid point of the rectangle
|
||||
glm::dvec3 center; // mid point of the rectangle
|
||||
float radius { -1.0f }; // radius of the bounding sphere
|
||||
|
||||
bounding_area() = default;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
material_handle material { null_handle };
|
||||
lighting_data lighting;
|
||||
// geometry data
|
||||
glm::highp_dvec3 origin; // world position of the relative coordinate system origin
|
||||
glm::dvec3 origin; // world position of the relative coordinate system origin
|
||||
gfx::geometry_handle geometry { 0, 0 }; // relative origin-centered chunk of geometry held by gfx renderer
|
||||
std::vector<world_vertex> vertices; // world space source data of the geometry
|
||||
gfx::userdata_array userdata;
|
||||
|
||||
7
stdafx.h
7
stdafx.h
@@ -94,6 +94,7 @@
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#define GLM_FORCE_CTOR_INIT
|
||||
#define GLM_FORCE_INLINE
|
||||
#define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
|
||||
#define GLM_FORCE_INTRINSICS
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
@@ -107,6 +108,12 @@
|
||||
#include <glm/gtx/norm.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#ifndef PACKED_VEC3_DEFINED
|
||||
#define PACKED_VEC3_DEFINED
|
||||
// 12-byte vec3 that stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES.
|
||||
// Use in structs that must match an exact binary layout (UBOs, vertex data, serialized formats).
|
||||
using packed_vec3 = glm::vec<3, float, glm::packed_highp>;
|
||||
#endif
|
||||
|
||||
|
||||
#include "rendering/openglmatrixstack.h"
|
||||
|
||||
Reference in New Issue
Block a user