Lazily initialize D3D11 mix-blend shaders. (bug 1246388, r=mattwoodrow)

This commit is contained in:
David Anderson 2016-02-12 17:15:33 -08:00
parent c386e3e379
commit 1474d26667

View File

@ -67,6 +67,7 @@ struct DeviceAttachmentsD3D11
{}
bool CreateShaders();
bool InitBlendShaders();
bool InitSyncObject();
typedef EnumeratedArray<MaskType, MaskType::NumMaskTypes, RefPtr<ID3D11VertexShader>>
@ -971,7 +972,9 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
gfx::IntRect rect = ComputeBackdropCopyRect(aRect, aClipRect, aTransform, &backdropTransform);
RefPtr<ID3D11ShaderResourceView> srv;
if (CopyBackdrop(rect, &mixBlendBackdrop, &srv)) {
if (CopyBackdrop(rect, &mixBlendBackdrop, &srv) &&
mAttachments->InitBlendShaders())
{
vertexShader = mAttachments->mVSQuadBlendShader[maskType];
pixelShader = mAttachments->mBlendShader[MaskType::MaskNone];
@ -1491,15 +1494,26 @@ DeviceAttachmentsD3D11::InitSyncObject()
return true;
}
bool
DeviceAttachmentsD3D11::InitBlendShaders()
{
if (!mVSQuadBlendShader[MaskType::MaskNone]) {
InitVertexShader(sLayerQuadBlendVS, mVSQuadBlendShader, MaskType::MaskNone);
InitVertexShader(sLayerQuadBlendMaskVS, mVSQuadBlendShader, MaskType::Mask2d);
InitVertexShader(sLayerQuadBlendMask3DVS, mVSQuadBlendShader, MaskType::Mask3d);
}
if (!mBlendShader[MaskType::MaskNone]) {
InitPixelShader(sBlendShader, mBlendShader, MaskType::MaskNone);
}
return mInitOkay;
}
bool
DeviceAttachmentsD3D11::CreateShaders()
{
InitVertexShader(sLayerQuadVS, mVSQuadShader, MaskType::MaskNone);
InitVertexShader(sLayerQuadMaskVS, mVSQuadShader, MaskType::Mask2d);
InitVertexShader(sLayerQuadMask3DVS, mVSQuadShader, MaskType::Mask3d);
InitVertexShader(sLayerQuadBlendVS, mVSQuadBlendShader, MaskType::MaskNone);
InitVertexShader(sLayerQuadBlendMaskVS, mVSQuadBlendShader, MaskType::Mask2d);
InitVertexShader(sLayerQuadBlendMask3DVS, mVSQuadBlendShader, MaskType::Mask3d);
InitPixelShader(sSolidColorShader, mSolidColorShader, MaskType::MaskNone);
InitPixelShader(sSolidColorShaderMask, mSolidColorShader, MaskType::Mask2d);
@ -1510,7 +1524,6 @@ DeviceAttachmentsD3D11::CreateShaders()
InitPixelShader(sRGBAShaderMask3D, mRGBAShader, MaskType::Mask3d);
InitPixelShader(sYCbCrShader, mYCbCrShader, MaskType::MaskNone);
InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask2d);
InitPixelShader(sBlendShader, mBlendShader, MaskType::MaskNone);
if (gfxPrefs::ComponentAlphaEnabled()) {
InitPixelShader(sComponentAlphaShader, mComponentAlphaShader, MaskType::MaskNone);
InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask2d);