diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f6db4471a0..fdf3bf805e 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -128,6 +128,8 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const D3D11Flush(d3d11->ctx); d3d11_free_shader_preset(d3d11); + d3d11->resize_fbos = true; + if (!path) return true; @@ -709,8 +711,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi switch (pass->fbo.type_x) { case RARCH_SCALE_INPUT: - if (pass->fbo.scale_x) - width *= pass->fbo.scale_x; + width *= pass->fbo.scale_x; break; case RARCH_SCALE_VIEWPORT: @@ -728,8 +729,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi switch (pass->fbo.type_y) { case RARCH_SCALE_INPUT: - if (pass->fbo.scale_y) - height *= pass->fbo.scale_y; + height *= pass->fbo.scale_y; break; case RARCH_SCALE_VIEWPORT: @@ -750,17 +750,18 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi if (!height) height = d3d11->vp.height; - d3d11->pass[i].viewport.Width = width; - d3d11->pass[i].viewport.Height = height; - d3d11->pass[i].viewport.MaxDepth = 1.0; - d3d11->pass[i].rt.desc.Width = width; - d3d11->pass[i].rt.desc.Height = height; - d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; - d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); + RARCH_LOG("[D3D11]: Updating framebuffer size %u x %u.\n", width, height); if ((i != (d3d11->shader_preset->passes - 1)) || (width != d3d11->vp.width) || (height != d3d11->vp.height)) { + d3d11->pass[i].viewport.Width = width; + d3d11->pass[i].viewport.Height = height; + d3d11->pass[i].viewport.MaxDepth = 1.0; + d3d11->pass[i].rt.desc.Width = width; + d3d11->pass[i].rt.desc.Height = height; + d3d11->pass[i].rt.desc.BindFlags = D3D11_BIND_RENDER_TARGET; + d3d11->pass[i].rt.desc.Format = glslang_format_to_dxgi(d3d11->pass[i].semantics.format); d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt); } else @@ -787,6 +788,7 @@ static bool d3d11_init_frame_textures(d3d11_video_t* d3d11, unsigned width, unsi } d3d11->resize_fbos = false; + return true; #if 0 error: @@ -844,6 +846,9 @@ static bool d3d11_gfx_frame( if (frame && width && height) { if (d3d11->frame.texture.desc.Width != width || d3d11->frame.texture.desc.Height != height) + d3d11->resize_fbos = true; + + if (d3d11->resize_fbos) d3d11_init_frame_textures(d3d11, width, height); d3d11_update_texture( @@ -853,10 +858,6 @@ static bool d3d11_gfx_frame( D3D11SetVertexBuffer(d3d11->ctx, 0, d3d11->frame.vbo, sizeof(d3d11_vertex_t), 0); D3D11SetBlendState(d3d11->ctx, d3d11->blend_disable, NULL, D3D11_DEFAULT_SAMPLE_MASK); - /* todo: single pass shaders can also have an empty rt texture */ - if (d3d11->shader_preset && (d3d11->resize_fbos || !d3d11->pass[0].rt.handle)) - d3d11_init_frame_textures(d3d11, width, height); - d3d11_texture_t* texture = &d3d11->frame.texture; if (d3d11->shader_preset) diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index b1f017eaff..552b1fae05 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -94,27 +94,33 @@ static bool slang_process_reflection( unordered_map texture_semantic_map; unordered_map texture_semantic_uniform_map; - string name = shader_info->pass[pass_number].alias; + for (unsigned i = 0; i <= pass_number; i++) + { + if(!*shader_info->pass[i].alias) + continue; - if (!set_unique_map( - texture_semantic_map, name, - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, pass_number })) - return false; + string name = shader_info->pass[i].alias; - if (!set_unique_map( - texture_semantic_uniform_map, name + "Size", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_map, name, + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) + return false; - if (!set_unique_map( - texture_semantic_map, name + "Feedback", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_uniform_map, name + "Size", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_OUTPUT, i })) + return false; - if (!set_unique_map( - texture_semantic_uniform_map, name + "FeedbackSize", - slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, pass_number })) - return false; + if (!set_unique_map( + texture_semantic_map, name + "Feedback", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) + return false; + + if (!set_unique_map( + texture_semantic_uniform_map, name + "FeedbackSize", + slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK, i })) + return false; + } for (unsigned i = 0; i < shader_info->luts; i++) { @@ -130,6 +136,7 @@ static bool slang_process_reflection( } unordered_map uniform_semantic_map; + for (unsigned i = 0; i < shader_info->num_parameters; i++) { if (!set_unique_map( @@ -305,6 +312,9 @@ bool slang_process( if (!slang_preprocess_parse_parameters(output.meta, shader_info)) return false; + if (!output.meta.name.empty()) + strncpy(pass.alias, output.meta.name.c_str(), sizeof(pass.alias) - 1); + out->format = output.meta.rt_format; if (out->format == SLANG_FORMAT_UNKNOWN) @@ -363,6 +373,31 @@ bool slang_process( ps_attrib_remap.push_back({ location, "SV_Position" }); } } + + /* "line" is a reserved keyword in hlsl + * maybe there is an easier way to rename a variable ? */ + + int id = 0; + while(true) + { + try + { + string name = ps->get_name(id); + + if(name == "line") + { + ps->set_name(id, "var_line"); + break; + } + + id++; + } + catch (const std::exception& e) + { + break; + } + } + VariableTypeRemapCallback ps_var_remap_cb = [](const SPIRType& type, const std::string& var_name, std::string& name_of_type) { if (var_name == "FragCoord")