win-capture: Support linear SRGB

For game capture, neither GL nor D3D9 support SRGB shared textures, so
disable linear SRGB support if the texture format doesn't support it.

Similarly, DXGI display capture doesn't work with SRGB at the moment.
Unsure if it will with more work, but disable for now.

Also force linear SRGB off if using GDI-compatible textures.
This commit is contained in:
jpark37
2021-01-20 08:20:51 -08:00
parent 015ed39923
commit a311299606
3 changed files with 24 additions and 1 deletions

View File

@@ -172,7 +172,15 @@ static void draw_texture(struct dc_capture *capture, gs_effect_t *effect)
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
size_t passes;
gs_effect_set_texture(image, texture);
const bool linear_srgb = gs_get_linear_srgb() && capture->compatibility;
const bool previous = gs_framebuffer_srgb_enabled();
gs_enable_framebuffer_srgb(linear_srgb);
if (linear_srgb)
gs_effect_set_texture_srgb(image, texture);
else
gs_effect_set_texture(image, texture);
passes = gs_technique_begin(tech);
for (size_t i = 0; i < passes; i++) {
@@ -186,6 +194,8 @@ static void draw_texture(struct dc_capture *capture, gs_effect_t *effect)
}
}
gs_technique_end(tech);
gs_enable_framebuffer_srgb(previous);
}
void dc_capture_render(struct dc_capture *capture, gs_effect_t *effect)