-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from Silverlan/develop
- Loading branch information
Showing
15 changed files
with
315 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ifndef F_SH_DEBUG_PRINT_GLS | ||
#define F_SH_DEBUG_PRINT_GLS | ||
|
||
// These have to match the enums in pragma/rendering/global_render_settings_buffer_data.hpp | ||
#define GLSL_TYPE_INT32 0 | ||
#define GLSL_TYPE_UINT32 1 | ||
#define GLSL_TYPE_FLOAT 2 | ||
#define GLSL_TYPE_BOOLEAN 3 | ||
#define GLSL_TYPE_VECTOR2 4 | ||
#define GLSL_TYPE_VECTOR3 5 | ||
#define GLSL_TYPE_VECTOR4 6 | ||
#define GLSL_TYPE_MAT4 7 | ||
#define GLSL_TYPE_VECTOR2I 8 | ||
#define GLSL_TYPE_VECTOR3I 9 | ||
#define GLSL_TYPE_VECTOR4I 10 | ||
#define GLSL_TYPE_NOT_SET 11 | ||
#define GLSL_TYPE_COUNT 12 | ||
#define GLSL_TYPE_LAST 11 | ||
|
||
layout(std140, LAYOUT_ID(RENDER_SETTINGS, DEBUG_PRINT)) buffer DebugPrintData { | ||
mat4 value; | ||
uint type; | ||
} u_debugPrintData; | ||
|
||
void print(int value) { | ||
u_debugPrintData.value[0][0] = value; | ||
u_debugPrintData.type = GLSL_TYPE_INT32; | ||
} | ||
|
||
void print(uint value) { | ||
u_debugPrintData.value[0][0] = value; | ||
u_debugPrintData.type = GLSL_TYPE_UINT32; | ||
} | ||
|
||
void print(float value) { | ||
u_debugPrintData.value[0][0] = value; | ||
u_debugPrintData.type = GLSL_TYPE_FLOAT; | ||
} | ||
|
||
void print(bool value) { | ||
u_debugPrintData.value[0][0] = value ? 1.0 : 0.0; | ||
u_debugPrintData.type = GLSL_TYPE_BOOLEAN; | ||
} | ||
|
||
void print(vec2 value) { | ||
u_debugPrintData.value[0] = vec4(value, 0.0, 0.0); | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR2; | ||
} | ||
|
||
void print(vec3 value) { | ||
u_debugPrintData.value[0] = vec4(value, 0.0); | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR3; | ||
} | ||
|
||
void print(vec4 value) { | ||
u_debugPrintData.value[0] = value; | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR4; | ||
} | ||
|
||
void print(mat4 value) { | ||
u_debugPrintData.value = value; | ||
u_debugPrintData.type = GLSL_TYPE_MAT4; | ||
} | ||
|
||
void print(ivec2 value) { | ||
u_debugPrintData.value[0] = vec4(value, 0.0, 0.0); | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR2I; | ||
} | ||
|
||
void print(ivec3 value) { | ||
u_debugPrintData.value[0] = vec4(value, 0.0); | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR3I; | ||
} | ||
|
||
void print(ivec4 value) { | ||
u_debugPrintData.value[0] = vec4(value); | ||
u_debugPrintData.type = GLSL_TYPE_VECTOR4I; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
core/client/include/pragma/rendering/global_render_settings_buffer_data.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright (c) 2024 Silverlan | ||
*/ | ||
|
||
#ifndef __PRAGMA_GLOBAL_RENDER_SETTINGS_BUFFER_DATA_HPP__ | ||
#define __PRAGMA_GLOBAL_RENDER_SETTINGS_BUFFER_DATA_HPP__ | ||
|
||
#include <memory> | ||
#include <buffers/prosper_buffer.hpp> | ||
#include <prosper_descriptor_set_group.hpp> | ||
#include <udm_enums.hpp> | ||
|
||
// #define PRAGMA_ENABLE_SHADER_DEBUG_PRINT | ||
|
||
namespace pragma::rendering { | ||
// These have to match the enums in shaders/debug/debug_print.glsl | ||
enum class GlslType : uint32_t { | ||
Int32 = 0, | ||
UInt32, | ||
|
||
Float, | ||
Boolean, | ||
|
||
Vector2, | ||
Vector3, | ||
Vector4, | ||
Mat4, | ||
|
||
Vector2i, | ||
Vector3i, | ||
Vector4i, | ||
|
||
NotSet, | ||
|
||
Count, | ||
Last = Count - 1, | ||
Invalid = std::numeric_limits<uint32_t>::max() | ||
}; | ||
constexpr udm::Type glsl_type_to_udm(GlslType type) | ||
{ | ||
switch(type) { | ||
case GlslType::Int32: | ||
return udm::Type::Int32; | ||
case GlslType::UInt32: | ||
return udm::Type::UInt32; | ||
case GlslType::Float: | ||
return udm::Type::Float; | ||
case GlslType::Boolean: | ||
return udm::Type::Boolean; | ||
case GlslType::Vector2: | ||
return udm::Type::Vector2; | ||
case GlslType::Vector3: | ||
return udm::Type::Vector3; | ||
case GlslType::Vector4: | ||
return udm::Type::Vector4; | ||
case GlslType::Mat4: | ||
return udm::Type::Mat4; | ||
case GlslType::Vector2i: | ||
return udm::Type::Vector2i; | ||
case GlslType::Vector3i: | ||
return udm::Type::Vector3i; | ||
case GlslType::Vector4i: | ||
return udm::Type::Vector4i; | ||
default: | ||
return udm::Type::Invalid; | ||
} | ||
} | ||
|
||
template<typename T> | ||
concept is_glsl_type = std::is_same_v<T, float> || std::is_same_v<T, bool> || std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t> || std::is_same_v<T, Mat4> || std::is_same_v<T, Vector4> || std::is_same_v<T, Vector3> || std::is_same_v<T, Vector2> || std::is_same_v<T, Vector4i> | ||
|| std::is_same_v<T, Vector3i> || std::is_same_v<T, Vector2i>; | ||
struct GlobalRenderSettingsBufferData { | ||
#ifdef PRAGMA_ENABLE_SHADER_DEBUG_PRINT | ||
#pragma pack(push, 1) | ||
struct DebugPrintData { | ||
uint8_t data[sizeof(Mat4)]; | ||
GlslType type = GlslType::NotSet; | ||
}; | ||
#pragma pack(pop) | ||
#endif | ||
|
||
GlobalRenderSettingsBufferData(); | ||
std::shared_ptr<prosper::IBuffer> debugBuffer = nullptr; | ||
std::shared_ptr<prosper::IBuffer> timeBuffer = nullptr; | ||
std::shared_ptr<prosper::IBuffer> csmBuffer = nullptr; | ||
#ifdef PRAGMA_ENABLE_SHADER_DEBUG_PRINT | ||
std::shared_ptr<prosper::IBuffer> debugPrintBuffer = nullptr; | ||
void EvaluateDebugPrint(); | ||
std::optional<std::string> GetDebugPrintString() const; | ||
void ResetDebugPrintData(); | ||
#endif | ||
std::shared_ptr<prosper::IDescriptorSetGroup> descSetGroup = nullptr; | ||
}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.