瀏覽代碼

libobs-d3d11: Fix gs_enable_color

It looks like the link between the gs layer rgba enable flags and the
underlying D3D states never got fully implemented.

This change adds the missing piece, fixing an issue I had in a plugin
wherein I couldn't write a blended value to a RGBA render target without
also changing the alpha of the dest pixel.  Debugging that led to the
missing gs_enable_color functionality.

Closes jp9000/obs-studio#1064
Micah Elizabeth Scott 8 年之前
父節點
當前提交
b55bb44845
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      libobs-d3d11/d3d11-subsystem.cpp

+ 4 - 1
libobs-d3d11/d3d11-subsystem.cpp

@@ -341,7 +341,10 @@ ID3D11BlendState *gs_device::AddBlendState()
 		bd.RenderTarget[i].DestBlendAlpha =
 			ConvertGSBlendType(blendState.destFactorA);
 		bd.RenderTarget[i].RenderTargetWriteMask =
-			D3D11_COLOR_WRITE_ENABLE_ALL;
+			(blendState.redEnabled   ? D3D11_COLOR_WRITE_ENABLE_RED   : 0) |
+			(blendState.greenEnabled ? D3D11_COLOR_WRITE_ENABLE_GREEN : 0) |
+			(blendState.blueEnabled  ? D3D11_COLOR_WRITE_ENABLE_BLUE  : 0) |
+			(blendState.alphaEnabled ? D3D11_COLOR_WRITE_ENABLE_ALPHA : 0) ;
 	}
 
 	SavedBlendState savedState(blendState, bd);