@@ -14,10 +14,11 @@ use crate::gfx::Device;
1414use crate :: gfx:: SwapChain ;
1515use crate :: gfx:: Texture ;
1616
17+ use maths_rs:: Vec4f ;
18+
1719use std:: ffi:: CStr ;
1820use std:: ffi:: CString ;
19-
20- use maths_rs:: Vec4f ;
21+ use std:: fs;
2122
2223use crate :: static_ref;
2324use crate :: static_ref_mut;
@@ -240,64 +241,24 @@ fn create_render_pipeline<D: Device, A: App>(info: &ImGuiInfo<D, A>) -> Result<D
240241 let device = & info. device ;
241242 let swap_chain = & info. swap_chain ;
242243
243- // TODO: temp: compile shaders
244- let src = "
245- cbuffer vertexBuffer : register(b0)
246- {
247- float4x4 ProjectionMatrix;
248- };
249- struct VS_INPUT
250- {
251- float2 pos : POSITION;
252- float4 col : COLOR0;
253- float2 uv : TEXCOORD0;
254- };
244+ let vsc_filepath = crate :: get_data_path ( "shaders/imgui/vs_main.vsc" ) ;
245+ let psc_filepath = crate :: get_data_path ( "shaders/imgui/ps_main.psc" ) ;
255246
256- struct PS_INPUT
257- {
258- float4 pos : SV_POSITION;
259- float4 col : COLOR0;
260- float2 uv : TEXCOORD0;
261- };
262-
263- PS_INPUT VSMain(VS_INPUT input)
264- {
265- PS_INPUT output;
266- output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.0, 1.0));
267- output.col = input.col;
268- output.uv = input.uv;
269- return output;
270- }
271-
272- SamplerState sampler0 : register(s0);
273- Texture2D texture0 : register(t0);
274-
275- float4 PSMain(PS_INPUT input) : SV_Target
276- {
277- float4 out_col = input.col * texture0.Sample(sampler0, input.uv);
278- return out_col;
279- }" ;
247+ let vsc_data = fs:: read ( vsc_filepath) ?;
248+ let psc_data = fs:: read ( psc_filepath) ?;
280249
281250 let vs_info = gfx:: ShaderInfo {
282251 shader_type : gfx:: ShaderType :: Vertex ,
283- compile_info : Some ( gfx:: ShaderCompileInfo {
284- entry_point : String :: from ( "VSMain" ) ,
285- target : String :: from ( "vs_5_0" ) ,
286- flags : gfx:: ShaderCompileFlags :: NONE ,
287- } ) ,
252+ compile_info : None
288253 } ;
289254
290- let fs_info = gfx:: ShaderInfo {
255+ let ps_info = gfx:: ShaderInfo {
291256 shader_type : gfx:: ShaderType :: Fragment ,
292- compile_info : Some ( gfx:: ShaderCompileInfo {
293- entry_point : String :: from ( "PSMain" ) ,
294- target : String :: from ( "ps_5_0" ) ,
295- flags : gfx:: ShaderCompileFlags :: NONE ,
296- } ) ,
257+ compile_info : None
297258 } ;
298259
299- let vs = device. create_shader ( & vs_info, src . as_bytes ( ) ) ?;
300- let fs = device. create_shader ( & fs_info , src . as_bytes ( ) ) ?;
260+ let vs = device. create_shader ( & vs_info, & vsc_data ) ?;
261+ let fs = device. create_shader ( & ps_info , & psc_data ) ?;
301262
302263 device. create_render_pipeline ( & gfx:: RenderPipelineInfo {
303264 vs : Some ( & vs) ,
0 commit comments