Commit 72ac9a19 authored by Johannes Braun's avatar Johannes Braun
Browse files

Added ability to render an empty scene. GAH!

parent 81a9a181
......@@ -7,7 +7,6 @@
#include <pathtracer/data/mesh_bvh.glsl>
#include <pathtracer/data/mesh_linespace.glsl>
//#include <raytracer/datastructure/mesh_angular_linespace.glsl>
bool traverseObjects(const in Ray ray, const in bool use_first, const in float max_distance, inout Hit hit, inout float t_min, bool force_bvh = false);
......@@ -30,7 +29,7 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
float t = t_min;
float max_dist = max_distance;
// Check once the AABB for the whole scene
bool hit_scene = ray.intersectsBounds(global_bvh_nodes_data[0].bounds, max_distance);
bool hit_scene = global_bvh_nodes_data.length() != 0 && ray.intersectsBounds(global_bvh_nodes_data[0].bounds, max_distance);
bool hit_triangle = false;
int current_node = 0;
......
......@@ -51,4 +51,11 @@ namespace glare::core
{
gl::unmapNamedBuffer(m_handle);
}
int64_t Buffer::size() const
{
int64_t s;
gl::getNamedBufferParameteri64v(m_handle, gl::GetNamedBufferParameters::eSize, &s);
return s;
}
}
\ No newline at end of file
......@@ -81,6 +81,8 @@ namespace glare::core
template<typename TReturn = void> TReturn* map(size_t count, gl::BufferMapBit flags) const;
void unmap() const;
int64_t size() const;
protected:
gl::handle::buffer m_handle;
uint64_t m_resident_address = 0;
......
......@@ -125,7 +125,7 @@ namespace glare::raytrace
template<typename TPrimitive>
void BVH<TPrimitive>::reset(std::vector<TPrimitive> &primitives)
{
m_ranges.clear();
m_ranges.clear();
m_nodes.resize(2 * primitives.size());
m_centroids.resize(primitives.size());
......@@ -160,6 +160,9 @@ namespace glare::raytrace
m_centroid_from_id = centroid_from_id;
m_make_bounds = make_bounds;
if (primitives.empty())
return;
const core::ClockMicros timer;
reset(primitives);
......
......@@ -63,7 +63,8 @@ namespace glare::raytrace
if (update_materials) {
m_material_buffer.upload(m_materials, gl::BufferUsage::eDynamicRead);
m_material_buffer.makeResident(gl::Access::eReadOnly);
if(m_material_buffer.size() != 0)
m_material_buffer.makeResident(gl::Access::eReadOnly);
}
if (update_meshes || update_mesh_transforms) {
......
......@@ -308,6 +308,11 @@ namespace gl
glGetNamedBufferParameterui64vNV(buffer, static_cast<GLenum>(parameter), data);
}
void getNamedBufferParameteri64v(unsigned buffer, GetNamedBufferParameters parameter, int64_t *data)
{
glGetNamedBufferParameteri64v(buffer, static_cast<GLenum>(parameter), data);
}
void memoryBarrier(MemoryBarrierBit barriers)
{
glMemoryBarrier(static_cast<GLbitfield>(barriers));
......
......@@ -207,7 +207,16 @@ namespace gl
enum class GetNamedBufferParameters
{
eGPUAddress = GL_BUFFER_GPU_ADDRESS_NV
eGPUAddress = GL_BUFFER_GPU_ADDRESS_NV,
eAccess = GL_BUFFER_ACCESS,
eAccessFlags = GL_BUFFER_ACCESS_FLAGS,
eImmutableStorage = GL_BUFFER_IMMUTABLE_STORAGE,
eMapped = GL_BUFFER_MAPPED,
eMapLength = GL_BUFFER_MAP_LENGTH,
eMapOffset = GL_BUFFER_MAP_OFFSET,
eSize = GL_BUFFER_SIZE,
eStorageFlags = GL_BUFFER_STORAGE_FLAGS,
eUsage = GL_BUFFER_USAGE
};
enum class EnableParameter
......@@ -889,6 +898,7 @@ namespace gl
void makeNamedBufferResident(unsigned buffer, Access access);
void makeNamedBufferNonResident(unsigned buffer);
void getNamedBufferParameterui64v(unsigned buffer, GetNamedBufferParameters parameter, uint64_t *data);
void getNamedBufferParameteri64v(unsigned buffer, GetNamedBufferParameters parameter, int64_t *data);
void memoryBarrier(MemoryBarrierBit barriers);
void genTextures(unsigned count, unsigned* textures);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment