Browse Source

libobs-d3d11: Make gs_clear honor FRAMEBUFFER_SRGB

This matches the behavior of glClearColor/glClear on OpenGL.
jpark37 3 years ago
parent
commit
1c4148408f
1 changed files with 11 additions and 5 deletions
  1. 11 5
      libobs-d3d11/d3d11-subsystem.cpp

+ 11 - 5
libobs-d3d11/d3d11-subsystem.cpp

@@ -2200,11 +2200,17 @@ void device_load_swapchain(gs_device_t *device, gs_swapchain_t *swapchain)
 void device_clear(gs_device_t *device, uint32_t clear_flags,
 		  const struct vec4 *color, float depth, uint8_t stencil)
 {
-	int side = device->curRenderSide;
-	if ((clear_flags & GS_CLEAR_COLOR) != 0 && device->curRenderTarget)
-		device->context->ClearRenderTargetView(
-			device->curRenderTarget->renderTarget[side],
-			color->ptr);
+	if (clear_flags & GS_CLEAR_COLOR) {
+		gs_texture_2d *const tex = device->curRenderTarget;
+		if (tex) {
+			const int side = device->curRenderSide;
+			ID3D11RenderTargetView *const rtv =
+				device->curFramebufferSrgb
+					? tex->renderTargetLinear[side]
+					: tex->renderTarget[side];
+			device->context->ClearRenderTargetView(rtv, color->ptr);
+		}
+	}
 
 	if (device->curZStencilBuffer) {
 		uint32_t flags = 0;