Commits

Lars Viklund committed 7901dd1

Optimization

  • Participants
  • Parent commits 84c6034

Comments (0)

Files changed (5)

File build_shaders.cmd

 fxc.exe /O3 /T vs_4_0_level_9_3 /Vn g_compose_line_vs /Fo g_compose_line_vs.cso /Fh g_compose_line_vs.h .\g_compose_line_vs.hlsl && ^
 fxc.exe /O3 /T ps_4_0_level_9_3 /Vn g_compose_line_ps /Fo g_compose_line_ps.cso /Fh g_compose_line_ps.h .\g_compose_line_ps.hlsl
 @echo Done!
-timeout 10
+timeout 1
 goto foo

File g_fpl_ps.hlsl

 struct PSInput {
-	float4 pos    : SV_Position;
-	float2 pos_xy : SCREEN_POSITION;
-	float2 from   : POINT0;
-	float2 to     : POINT1;
-	float width   : WIDTH;
+	float4 pos   : SV_Position;
+	float2 p     : REL_P;
+	float2 p1    : REL_P1;
+	float2 major : MAJOR_AXIS;
+	float width  : WIDTH;
 };
 
 float4 main(PSInput input) : SV_Target {
 	float inv_width = 1.0 / input.width;
-	float2 p0 = float2(0, 0);
-	float2 p1 = input.to - input.from;
-	float2 p = input.pos_xy - input.from;
-	float d0 = 1.0 - saturate(length(input.pos_xy - input.from) * inv_width);
-	float d1 = 1.0 - saturate(length(input.pos_xy - input.to)   * inv_width);
+	float2 p1 = input.p1;
+	float2 p = input.p;
+	float d0 = 1.0 - saturate(length(p) * inv_width);
+	float d1 = 1.0 - saturate(length(p - p1)   * inv_width);
 
 	float len = length(p1);
-	float2 along = float2(p1/len);
+	float2 along = input.major;
 	float2 across = float2(along.y, -along.x);
 	float d2 = abs(dot(float3(across, 0), float3(p, 1)) * inv_width);
 	d2 = 1.0 - saturate(d2);

File g_fpl_vs.hlsl

 };
 
 struct PSInput {
-	float4 pos : SV_Position;
-	float2 pos_xy : SCREEN_POSITION;
-	float2 from : POINT0;
-	float2 to   : POINT1;
-	float width : WIDTH;
+	float4 pos   : SV_Position;
+	float2 p     : REL_P;
+	float2 p1    : REL_P1;
+	float2 major : MAJOR_AXIS;
+	float width  : WIDTH;
 };
 
 cbuffer matrix_buffer
 	float x_id = (vtx_id%2);
     float y_id = (vtx_id/2);
 
-    float w = input.width*5;
+    float w = input.width;
 	float R = input.r;
     float2 mid = (input.to + input.from)/2;
     float2 A = input.to - input.from;
 //        + (x_id*2 - 1.0) * float2(window_extents.x, 0)
 //        - (y_id*2 - 1.0) * float2(0, window_extents.y);
 	output.pos = float4(2.0 * v / window_extents - 1.0, 0.5, 1.0);
-	output.pos_xy = v;
-	output.from = input.from;
-	output.to = input.to;
+	output.p = v - input.from;
+	output.p1 = input.to - input.from;
+	output.major = A;
 	output.width = (input.width + input.r)/2;
 	return output;
 }
 			_spline_drawer->update();
 			_spline_drawer->draw();
 		}
-		UINT present_interval = 0;
+		UINT present_interval = 1;
 		DWORD present_flag = 0;
 		_view->target()._swap_chain->Present(present_interval, present_flag);
 	}

File oscilloscope.cc

 	auto ndc_to_window = [&](Float2 ndc) {
 		return (ndc + 1.0f)/2.0f * window_extents;
 	};
-
-	float w = 10.0f;
-	float r = 0.5f;
-
-#if DRAW_POINTLESS_TIME_BARS
-	std::vector<FPLInstance> instances;
-	if (time_lines.size() > 0) {
-		instances.reserve(time_lines.size());
-		for (auto x : time_lines) {
-			FPLInstance instance;
-			auto x0 = x, y0 = -1.0f;
-			auto x1 = x, y1 =  1.0f;
-			Float2 p0 = instance.from = ndc_to_window(Float2{x0, y0});
-			Float2 p1 = instance.to = ndc_to_window(Float2{x1, y1});
-			instance.width = w;
-			instance.r = r;
-			instances.emplace_back(std::move(instance));
-		}
-		create_or_update_buffer(_view->device, _view->context, instances, _time_line_instances, _num_time_line_instances);
-	}
-#endif
 }
 
 void SplineDrawer::update_spline(float zoom, float const* points, size_t num_elements) {
 			instances.emplace_back(std::move(instance));
 		}
 	}
+	if (0) // debug line
+	{
+		FPLInstance instance;
+		Float2 p0 = ndc_to_window({ -0.8f,  0.3f });
+		Float2 p1 = ndc_to_window({  0.8f,  0.5f });
+		instance.from = p0;
+		instance.to = p1;
+		float w = 15.0f;
+		instance.width = w;
+		instance.r = r;
+		instances.emplace_back(std::move(instance));
+	}
 #if 0
 	for (float f = 1.0f; f <= 1.0f; f += 2.0f) {
 		FPLInstance instance;
 		float w = 15.0f;
 		instance.width = w;
 		instance.r = r;
-		edge_equations_for_fat_line(r+w/2.0f, instance.from, instance.to, instance.edges);
 		instances.emplace_back(std::move(instance));
 	}
 #endif