Skip to content

Commit

Permalink
fix(shaders/directx): replace modulus with bitwise operator (LizardBy…
Browse files Browse the repository at this point in the history
  • Loading branch information
iMakeSoftware authored and qiin2333 committed Dec 31, 2024
1 parent 56bcaeb commit 97d0f61
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ namespace confighttp {
resolutions_nodes.push_back(std::make_pair("resolution"s, res_node));
}

std::string idd_option_path = "c:\\IddSampleDriver\\vdd_settings.xml";
std::string idd_option_path = "c:\\VirtualDisplayDriver\\vdd_settings.xml";
if (fs::exists(idd_option_path)) {
pt::ptree monitor_node;
monitor_node.put("count", 1);
Expand Down
20 changes: 9 additions & 11 deletions src/display_device/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,15 @@ namespace display_device {

std::unique_ptr<session_t::deinit_t>
session_t::init() {
if (session_t::get().settings.is_changing_settings_going_to_fail()) {
const auto devices { enum_available_devices() };
const auto vdd_devices { display_device::find_device_by_friendlyname(zako_name) };
if (!devices.empty()) {
BOOST_LOG(info) << "Available display devices: " << to_string(devices);
zako_device_id = vdd_devices;
// 大多数哔叽本开机默认虚拟屏优先导致黑屏
if (!vdd_devices.empty() && devices.size() > 1) {
session_t::get().disable_vdd();
std::this_thread::sleep_for(2333ms);
}
const auto devices { enum_available_devices() };
const auto vdd_devices { display_device::find_device_by_friendlyname(zako_name) };
if (!devices.empty()) {
BOOST_LOG(info) << "Available display devices: " << to_string(devices);
zako_device_id = vdd_devices;
// 大多数哔叽本开机默认虚拟屏优先导致黑屏
if (!vdd_devices.empty() && devices.size() > 1) {
session_t::get().disable_vdd();
std::this_thread::sleep_for(2333ms);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src_assets/windows/assets/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
{
"name": "禁用虚拟显示器",
"cmd": "C:\\Program Files\\Sunshine\\tools\\device-toggler.exe 2 2 \"Virtual Display with HDR\"",
"cmd": "C:\\Program Files\\Sunshine\\tools\\device-toggler.exe 2 2 \"VirtualDisplayDriver\"",
"elevated": "true"
},
{
Expand Down
26 changes: 17 additions & 9 deletions src_assets/windows/assets/shaders/directx/include/base_vs.hlsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include "include/base_vs_types.hlsl"

#if defined(LEFT_SUBSAMPLING)
vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float subsample_offset, int rotate_texture_steps)
#elif defined(TOPLEFT_SUBSAMPLING)
vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_offset, int rotate_texture_steps)
#else
vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, int rotate_texture_steps)
#endif
{
vertex_t output;
float2 tex_coord;
Expand All @@ -30,16 +24,30 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, int rotate_texture_
sin(rotation_radians), cos(rotation_radians) };
float2 rotation_center = { 0.5, 0.5 };
tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center));

// Swap the xy offset coordinates if the texture is rotated an odd number of times.
if (rotate_texture_steps & 1) {
subsample_offset.xy = subsample_offset.yx;
}
}

#if defined(LEFT_SUBSAMPLING)
output.tex_right_left_center = float3(tex_coord.x, tex_coord.x - subsample_offset, tex_coord.y);
#elif defined (TOPLEFT_SUBSAMPLING)
output.tex_right_left_center = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y);
#elif defined(LEFT_SUBSAMPLING_SCALE)
float2 halfsample_offset = subsample_offset / 2;
float3 right_center_left = float3(tex_coord.x + halfsample_offset.x,
tex_coord.x - halfsample_offset.x,
tex_coord.x - 3 * halfsample_offset.x);
float2 top_bottom = float2(tex_coord.y - halfsample_offset.y,
tex_coord.y + halfsample_offset.y);
output.tex_right_center_left_top = float4(right_center_left, top_bottom.x);
output.tex_right_center_left_bottom = float4(right_center_left, top_bottom.y);
#elif defined(TOPLEFT_SUBSAMPLING)
output.tex_right_left_top = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y - subsample_offset.y);
output.tex_right_left_bottom = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y);
#else
output.tex_coord = tex_coord;
#endif

return output;
}
}

0 comments on commit 97d0f61

Please sign in to comment.