Commit ce942e62 authored by Daniel Bross's avatar Daniel Bross
Browse files

Improved MacOS performance.

parent 63df6510
File added
export PATH=/Users/danielbross/glitchheart/glitchheartengine/glitch_tool/build:$PATH
export GLITCH_ENGINE=/Users/danielbross/glitchheart/glitchheartengine
File added
#!/bin/bash
EXECUTABLE_NAME=altered
DEBUG=-DDEBUG=0
DEBUG=-DDEBUG=1
OPT=-O0
WIGNORE="-Wno-reserved-id-macro -Wno-deprecated -Wno-format-nonliteral -Wno-int-to-void-pointer-cast -Wno-undef -Wno-missing-variable-declarations -Wno-nested-anon-types -Wno-variadic-macros -Wno-old-style-cast -Wno-sign-conversion -Wno-cast-align -Wno-gnu-anonymous-struct -Wno-c++98-compat -Wno-padded -Wdocumentation -Wdocumentation-unknown-command -Wno-double-promotion -Wno-c++98-compat-pedantic -Wno-missing-prototypes -Wno-float-equal -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments -Wno-writable-strings -Wno-global-constructors -Wno-switch-enum -Wno-char-subscripts -Wno-unused-function"
......
......@@ -482,9 +482,9 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
standard_info.width = renderer->framebuffer_width;
standard_info.height = renderer->framebuffer_height;
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 8);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 8);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, standard_info, 8);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 2);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 2);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, standard_info, 2);
rendering::FramebufferHandle standard_framebuffer = rendering::create_framebuffer(standard_info, renderer);
rendering::RenderPassHandle standard = rendering::create_render_pass(STANDARD_PASS, standard_framebuffer, renderer);
......@@ -517,8 +517,8 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
final_info.width = renderer->framebuffer_width;
final_info.height = renderer->framebuffer_height;
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, final_info, 8);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_TEXTURE | rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, final_info, 8);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, final_info, 4);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_TEXTURE | rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, final_info, 4);
rendering::FramebufferHandle final_framebuffer = rendering::create_framebuffer(final_info, renderer);
rendering::set_final_framebuffer(renderer, final_framebuffer);
......@@ -954,7 +954,6 @@ int main(int argc, char **args)
//u32 target_fps = (u32)refresh_rate;
//r32 expected_frames_per_update = 1.0f;
//r32 seconds_per_frame = expected_frames_per_update / target_fps;
r64 last_frame = get_time();
r64 delta_time = 0.0;
renderer->frame_lock = 0;
......@@ -987,7 +986,6 @@ int main(int argc, char **args)
//#endif
//auto game_temp_mem = begin_temporary_memory(game_memory.temp_arena);
poll_events();
if (controller_present())
{
......@@ -1035,9 +1033,12 @@ int main(int argc, char **args)
update_log();
swap_buffers(render_state);
poll_events();
frames++;
r64 end_counter = get_time();
r64 time = get_time();
r64 end_counter = time;
if (end_counter - last_second_check >= 1.0)
{
last_second_check = end_counter;
......@@ -1045,12 +1046,12 @@ int main(int argc, char **args)
frames = 0;
}
delta_time = get_time() - last_frame;
delta_time = time - last_frame;
// @Incomplete: Fix this!
delta_time = math::clamp(0.0, delta_time, 0.9);
game_memory.core.delta_time = delta_time;
game_memory.core.current_time = get_time();
game_memory.core.current_time = time;
last_frame = end_counter;
}
......
......@@ -1387,6 +1387,8 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
#endif
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 4);
render_state.contrast = contrast;
render_state.brightness = brightness;
......@@ -1418,7 +1420,7 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
// @Note: If no window has been created, try and see if 3.3 works
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
create_open_gl_window(render_state, window_mode, title, screen_width, screen_height);
renderer->window_mode = window_mode;
......@@ -1910,6 +1912,11 @@ static void set_uniform(rendering::Transform transform, const rendering::RenderP
// (*texture_count++);
}
break;
case rendering::UniformMappingType::SHADOW_MAP_SIZE:
{
set_float_uniform(gl_shader.program, location, (r32)renderer->render.shadow_settings.size);
}
break;
case rendering::UniformMappingType::SHADOW_VIEW_POSITION:
{
set_vec3_uniform(gl_shader.program, location, renderer->render.shadow_view_position);
......@@ -2565,11 +2572,14 @@ static void render_all_passes(RenderState &render_state, Renderer *renderer)
// @Incomplete: Create a better way for enabling/disabling the clipping planes
// Check if we have clipping planes
glEnable(GL_CLIP_PLANE0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
rendering::RenderPass &shadow_pass = renderer->render.passes[renderer->render.shadow_pass.handle - 1];
render_pass(render_state, renderer, shadow_pass);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Go backwards through the array to enable easy render pass adding
for (i32 pass_index = renderer->render.pass_count - 1; pass_index >= 0; pass_index--)
{
......
......@@ -7,7 +7,6 @@
#include <GLFW/glfw3.h>
struct ShaderGL
{
GLuint program;
......@@ -162,4 +161,4 @@ struct RenderingState
RenderingState rendering_state;
#endif
#endif
\ No newline at end of file
......@@ -129,6 +129,7 @@ namespace rendering
DISSOLVE,
SHADOW_MAP,
SHADOW_MAP_SIZE,
SHADOW_VIEW_POSITION,
MODEL,
VIEW,
......
......@@ -675,6 +675,7 @@ struct Renderer
r32 z_near;
r32 z_far;
r32 fov;
i32 size;
} shadow_settings;
struct
......
......@@ -1874,6 +1874,7 @@ static Camera get_standard_camera(SceneManager& manager)
renderer->render.shadow_settings.z_near = settings.shadows.near_plane;
renderer->render.shadow_settings.z_far = settings.shadows.far_plane;
renderer->render.shadow_settings.fov = settings.shadows.fov;
renderer->render.shadow_settings.size = settings.shadows.map_width;
update_shadow_framebuffer(handle);
update_scene_camera(handle);
......
......@@ -231,6 +231,10 @@ namespace rendering
{
type = UniformMappingType::BUMP_TEX;
}
else if (starts_with(mapped_buffer, "SHADOW_MAP_SIZE"))
{
type = UniformMappingType::SHADOW_MAP_SIZE;
}
else if (starts_with(mapped_buffer, "SHADOW_MAP"))
{
type = UniformMappingType::SHADOW_MAP;
......
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