mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
refactor: consolidate QueryTimer struct to shared header
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
Move QueryTimer from m2_renderer.cpp and wmo_renderer.cpp to vk_frame_data.hpp for reuse. Removes 13 lines of duplicate code.
This commit is contained in:
parent
b5a2175269
commit
4be7910fdf
3 changed files with 20 additions and 33 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
namespace wowee {
|
namespace wowee {
|
||||||
namespace rendering {
|
namespace rendering {
|
||||||
|
|
@ -41,5 +42,22 @@ struct ShadowParamsUBO {
|
||||||
float foliageMotionDamp;
|
float foliageMotionDamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Timer utility for performance profiling queries
|
||||||
|
struct QueryTimer {
|
||||||
|
double* totalMs = nullptr;
|
||||||
|
uint32_t* callCount = nullptr;
|
||||||
|
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
||||||
|
QueryTimer(double* total, uint32_t* calls) : totalMs(total), callCount(calls) {}
|
||||||
|
~QueryTimer() {
|
||||||
|
if (callCount) {
|
||||||
|
(*callCount)++;
|
||||||
|
}
|
||||||
|
if (totalMs) {
|
||||||
|
auto end = std::chrono::steady_clock::now();
|
||||||
|
*totalMs += std::chrono::duration<double, std::milli>(end - start).count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace rendering
|
} // namespace rendering
|
||||||
} // namespace wowee
|
} // namespace wowee
|
||||||
|
|
|
||||||
|
|
@ -192,22 +192,6 @@ float pointAABBDistanceSq(const glm::vec3& p, const glm::vec3& bmin, const glm::
|
||||||
return glm::dot(d, d);
|
return glm::dot(d, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct QueryTimer {
|
|
||||||
double* totalMs = nullptr;
|
|
||||||
uint32_t* callCount = nullptr;
|
|
||||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
|
||||||
QueryTimer(double* total, uint32_t* calls) : totalMs(total), callCount(calls) {}
|
|
||||||
~QueryTimer() {
|
|
||||||
if (callCount) {
|
|
||||||
(*callCount)++;
|
|
||||||
}
|
|
||||||
if (totalMs) {
|
|
||||||
auto end = std::chrono::steady_clock::now();
|
|
||||||
*totalMs += std::chrono::duration<double, std::milli>(end - start).count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Möller–Trumbore ray-triangle intersection.
|
// Möller–Trumbore ray-triangle intersection.
|
||||||
// Returns distance along ray if hit, negative if miss.
|
// Returns distance along ray if hit, negative if miss.
|
||||||
float rayTriangleIntersect(const glm::vec3& origin, const glm::vec3& dir,
|
float rayTriangleIntersect(const glm::vec3& origin, const glm::vec3& dir,
|
||||||
|
|
|
||||||
|
|
@ -2492,22 +2492,6 @@ static float pointAABBDistanceSq(const glm::vec3& p, const glm::vec3& bmin, cons
|
||||||
return glm::dot(d, d);
|
return glm::dot(d, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct QueryTimer {
|
|
||||||
double* totalMs = nullptr;
|
|
||||||
uint32_t* callCount = nullptr;
|
|
||||||
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
|
|
||||||
QueryTimer(double* total, uint32_t* calls) : totalMs(total), callCount(calls) {}
|
|
||||||
~QueryTimer() {
|
|
||||||
if (callCount) {
|
|
||||||
(*callCount)++;
|
|
||||||
}
|
|
||||||
if (totalMs) {
|
|
||||||
auto end = std::chrono::steady_clock::now();
|
|
||||||
*totalMs += std::chrono::duration<double, std::milli>(end - start).count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Möller–Trumbore ray-triangle intersection
|
// Möller–Trumbore ray-triangle intersection
|
||||||
// Returns distance along ray if hit, or negative if miss
|
// Returns distance along ray if hit, or negative if miss
|
||||||
static float rayTriangleIntersect(const glm::vec3& origin, const glm::vec3& dir,
|
static float rayTriangleIntersect(const glm::vec3& origin, const glm::vec3& dir,
|
||||||
|
|
@ -3599,12 +3583,13 @@ void WMORenderer::recreatePipelines() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Vertex input ---
|
// --- Vertex input ---
|
||||||
|
// WMO vertex: pos3 + normal3 + texCoord2 + color4 + tangent4 = 64 bytes
|
||||||
struct WMOVertexData {
|
struct WMOVertexData {
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
glm::vec3 normal;
|
glm::vec3 normal;
|
||||||
glm::vec2 texCoord;
|
glm::vec2 texCoord;
|
||||||
glm::vec4 color;
|
glm::vec4 color;
|
||||||
glm::vec4 tangent;
|
glm::vec4 tangent; // xyz=tangent dir, w=handedness ±1
|
||||||
};
|
};
|
||||||
|
|
||||||
VkVertexInputBindingDescription vertexBinding{};
|
VkVertexInputBindingDescription vertexBinding{};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue