Backed out 3 changesets (bug 1340398) for static build bustage a=backout

Backed out changeset 7d0a9bb0a642 (bug 1340398)
Backed out changeset a8af64e23154 (bug 1340398)
Backed out changeset 588942cf8807 (bug 1340398)

MozReview-Commit-ID: BZveA35jLBL

--HG--
extra : rebase_source : 4e182afdb98d0422e82f184f5bfc332f27438f0a
This commit is contained in:
Wes Kocher 2017-03-07 13:39:49 -08:00
Родитель a5e82bccb0
Коммит af86144916
13 изменённых файлов: 2944 добавлений и 4372 удалений

Просмотреть файл

@ -20,7 +20,6 @@
#include "mozilla/layers/D3D11ShareHandleImage.h"
#include "mozilla/layers/ImageBridgeChild.h"
#include "mozilla/layers/TextureForwarder.h"
#include "mozilla/layers/TextureD3D11.h"
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
@ -85,8 +84,6 @@ using layers::D3D9SurfaceImage;
using layers::D3D9RecycleAllocator;
using layers::D3D11ShareHandleImage;
using layers::D3D11RecycleAllocator;
using namespace layers;
using namespace gfx;
class D3D9DXVA2Manager : public DXVA2Manager
{
@ -596,11 +593,7 @@ public:
virtual ~D3D11DXVA2Manager();
HRESULT Init(layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice);
HRESULT InitInternal(layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice);
nsACString& aFailureReason);
IUnknown* GetDXVADeviceManager() override;
@ -610,9 +603,6 @@ public:
const nsIntRect& aRegion,
Image** aOutImage) override;
virtual HRESULT CopyToBGRATexture(ID3D11Texture2D *aInTexture,
ID3D11Texture2D** aOutTexture);
HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight) override;
bool IsD3D11() override { return true; }
@ -635,12 +625,10 @@ private:
CreateDecoder(const D3D11_VIDEO_DECODER_DESC& aDesc) const;
RefPtr<ID3D11Device> mDevice;
RefPtr<ID3D11DeviceContext> mContext;
RefPtr<IMFDXGIDeviceManager> mDXGIDeviceManager;
RefPtr<MFTDecoder> mTransform;
RefPtr<D3D11RecycleAllocator> mTextureClientAllocator;
RefPtr<ID3D11VideoDecoder> mDecoder;
RefPtr<layers::SyncObject> mSyncObject;
GUID mDecoderGUID;
uint32_t mWidth = 0;
uint32_t mHeight = 0;
@ -667,20 +655,13 @@ D3D11DXVA2Manager::GetDXVADeviceManager()
MutexAutoLock lock(mLock);
return mDXGIDeviceManager;
}
HRESULT
D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice)
nsACString& aFailureReason)
{
if (!NS_IsMainThread()) {
// DXVA Managers used for full video have to be initialized on the main
// thread. Managers initialized off the main thread have to pass a device
// and can only be used for color conversion.
MOZ_ASSERT(aDevice);
return InitInternal(aKnowsCompositor, aFailureReason, aDevice);
}
HRESULT hr;
ScopedGfxFeatureReporter reporter("DXVA2D3D11");
gfx::D3D11VideoCrashGuard crashGuard;
@ -690,65 +671,12 @@ D3D11DXVA2Manager::Init(layers::KnowsCompositor* aKnowsCompositor,
return E_FAIL;
}
hr = InitInternal(aKnowsCompositor, aFailureReason, aDevice);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
if (layers::ImageBridgeChild::GetSingleton() || !aKnowsCompositor) {
// There's no proper KnowsCompositor for ImageBridge currently (and it
// implements the interface), so just use that if it's available.
mTextureClientAllocator = new D3D11RecycleAllocator(
layers::ImageBridgeChild::GetSingleton().get(), mDevice);
if (ImageBridgeChild::GetSingleton() && gfxPrefs::PDMWMFUseSyncTexture()) {
// We use a syncobject to avoid the cost of the mutex lock when compositing,
// and because it allows color conversion ocurring directly from this texture
// DXVA does not seem to accept IDXGIKeyedMutex textures as input.
mSyncObject =
layers::SyncObject::CreateSyncObject(layers::ImageBridgeChild::GetSingleton()->
GetTextureFactoryIdentifier().mSyncHandle,
mDevice);
}
} else {
mTextureClientAllocator =
new D3D11RecycleAllocator(aKnowsCompositor, mDevice);
if (gfxPrefs::PDMWMFUseSyncTexture()) {
// We use a syncobject to avoid the cost of the mutex lock when compositing,
// and because it allows color conversion ocurring directly from this texture
// DXVA does not seem to accept IDXGIKeyedMutex textures as input.
mSyncObject =
layers::SyncObject::CreateSyncObject(aKnowsCompositor->GetTextureFactoryIdentifier().mSyncHandle,
mDevice);
}
}
mTextureClientAllocator->SetMaxPoolSize(5);
Telemetry::Accumulate(Telemetry::MEDIA_DECODER_BACKEND_USED,
uint32_t(media::MediaDecoderBackend::WMFDXVA2D3D11));
reporter.SetSuccessful();
return S_OK;
}
HRESULT
D3D11DXVA2Manager::InitInternal(layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice)
{
HRESULT hr;
mDevice = aDevice;
mDevice = gfx::DeviceManagerDx::Get()->CreateDecoderDevice();
if (!mDevice) {
mDevice = gfx::DeviceManagerDx::Get()->CreateDecoderDevice();
if (!mDevice) {
aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
return E_FAIL;
}
aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
return E_FAIL;
}
mDevice->GetImmediateContext(getter_AddRefs(mContext));
hr = wmf::MFCreateDXGIDeviceManager(&mDeviceManagerToken,
getter_AddRefs(mDXGIDeviceManager));
if (!SUCCEEDED(hr)) {
@ -854,6 +782,22 @@ D3D11DXVA2Manager::InitInternal(layers::KnowsCompositor* aKnowsCompositor,
}
}
if (layers::ImageBridgeChild::GetSingleton()) {
// There's no proper KnowsCompositor for ImageBridge currently (and it
// implements the interface), so just use that if it's available.
mTextureClientAllocator = new D3D11RecycleAllocator(
layers::ImageBridgeChild::GetSingleton().get(), mDevice);
} else {
mTextureClientAllocator =
new D3D11RecycleAllocator(aKnowsCompositor, mDevice);
}
mTextureClientAllocator->SetMaxPoolSize(5);
Telemetry::Accumulate(Telemetry::MEDIA_DECODER_BACKEND_USED,
uint32_t(media::MediaDecoderBackend::WMFDXVA2D3D11));
reporter.SetSuccessful();
return S_OK;
}
@ -883,144 +827,42 @@ D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
{
NS_ENSURE_TRUE(aVideoSample, E_POINTER);
NS_ENSURE_TRUE(aOutImage, E_POINTER);
NS_ENSURE_TRUE(mSyncObject, E_FAIL);
MOZ_ASSERT(mTextureClientAllocator);
// Our video frame is stored in a non-sharable ID3D11Texture2D. We need
// to create a copy of that frame as a sharable resource, save its share
// handle, and put that handle into the rendering pipeline.
RefPtr<D3D11ShareHandleImage> image =
new D3D11ShareHandleImage(gfx::IntSize(mWidth, mHeight), aRegion);
bool ok = image->AllocateTexture(mTextureClientAllocator, mDevice);
NS_ENSURE_TRUE(ok, E_FAIL);
RefPtr<TextureClient> client = image->GetTextureClient(ImageBridgeChild::GetSingleton().get());
NS_ENSURE_TRUE(client, E_FAIL);
HRESULT hr = mTransform->Input(aVideoSample);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IDXGIKeyedMutex> mutex;
HRESULT hr;
RefPtr<IMFSample> sample;
RefPtr<ID3D11Texture2D> texture = image->GetTexture();
texture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
if (mutex) {
hr = mutex->AcquireSync(0, 2000);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = mutex->AcquireSync(0, 2000);
if (hr != S_OK) {
NS_WARNING("Acquire sync didn't manage to return within 2 seconds.");
}
if (client && client->GetFormat() == SurfaceFormat::NV12) {
// Our video frame is stored in a non-sharable ID3D11Texture2D. We need
// to create a copy of that frame as a sharable resource, save its share
// handle, and put that handle into the rendering pipeline.
hr = CreateOutputSample(sample, texture);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFMediaBuffer> buffer;
hr = aVideoSample->GetBufferByIndex(0, getter_AddRefs(buffer));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFDXGIBuffer> dxgiBuf;
hr = buffer->QueryInterface((IMFDXGIBuffer**)getter_AddRefs(dxgiBuf));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<ID3D11Texture2D> tex;
hr = dxgiBuf->GetResource(__uuidof(ID3D11Texture2D), getter_AddRefs(tex));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
UINT index;
dxgiBuf->GetSubresourceIndex(&index);
mContext->CopySubresourceRegion(texture, 0, 0, 0, 0, tex, index, nullptr);
} else {
// Our video sample is in NV12 format but our output texture is in BGRA.
// Use MFT to do color conversion.
hr = mTransform->Input(aVideoSample);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFSample> sample;
hr = CreateOutputSample(sample, texture);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = mTransform->Output(&sample);
}
if (!mutex) {
client->SyncWithObject(mSyncObject);
mSyncObject->FinalizeFrame();
} else {
mutex->ReleaseSync(0);
}
hr = mTransform->Output(&sample);
mutex->ReleaseSync(0);
image.forget(aOutImage);
return S_OK;
}
HRESULT
D3D11DXVA2Manager::CopyToBGRATexture(ID3D11Texture2D *aInTexture,
ID3D11Texture2D** aOutTexture)
{
NS_ENSURE_TRUE(aInTexture, E_POINTER);
NS_ENSURE_TRUE(aOutTexture, E_POINTER);
HRESULT hr;
RefPtr<ID3D11Texture2D> texture, inTexture;
inTexture = aInTexture;
CD3D11_TEXTURE2D_DESC desc;
aInTexture->GetDesc(&desc);
ConfigureForSize(desc.Width, desc.Height);
RefPtr<IDXGIKeyedMutex> mutex;
inTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
// The rest of this function will not work if inTexture implements
// IDXGIKeyedMutex! In that case case we would have to copy to a
// non-mutex using texture.
if (mutex) {
RefPtr<ID3D11Texture2D> newTexture;
desc.MiscFlags = 0;
hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(newTexture));
NS_ENSURE_TRUE(SUCCEEDED(hr) && newTexture, E_FAIL);
hr = mutex->AcquireSync(0, 2000);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
mContext->CopyResource(newTexture, inTexture);
mutex->ReleaseSync(0);
inTexture = newTexture;
}
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(texture));
NS_ENSURE_TRUE(SUCCEEDED(hr) && texture, E_FAIL);
RefPtr<IMFSample> inputSample;
wmf::MFCreateSample(getter_AddRefs(inputSample));
// If these aren't set the decoder fails.
inputSample->SetSampleTime(10);
inputSample->SetSampleDuration(10000);
RefPtr<IMFMediaBuffer> inputBuffer;
hr = wmf::MFCreateDXGISurfaceBuffer(
__uuidof(ID3D11Texture2D), inTexture, 0, FALSE, getter_AddRefs(inputBuffer));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
inputSample->AddBuffer(inputBuffer);
hr = mTransform->Input(inputSample);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFSample> outputSample;
hr = CreateOutputSample(outputSample, texture);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = mTransform->Output(&outputSample);
texture.forget(aOutTexture);
return S_OK;
}
HRESULT ConfigureOutput(IMFMediaType* aOutput, void* aData)
{
HRESULT hr =
@ -1077,7 +919,7 @@ D3D11DXVA2Manager::ConfigureForSize(uint32_t aWidth, uint32_t aHeight)
hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_ARGB32);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
gfx::IntSize size(mWidth, mHeight);
@ -1161,8 +1003,7 @@ D3D11DXVA2Manager::CreateDecoder(const D3D11_VIDEO_DECODER_DESC& aDesc) const
/* static */
DXVA2Manager*
DXVA2Manager::CreateD3D11DXVA(layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice)
nsACString& aFailureReason)
{
// DXVA processing takes up a lot of GPU resources, so limit the number of
// videos we use DXVA with at any one time.
@ -1174,7 +1015,7 @@ DXVA2Manager::CreateD3D11DXVA(layers::KnowsCompositor* aKnowsCompositor,
}
nsAutoPtr<D3D11DXVA2Manager> manager(new D3D11DXVA2Manager());
HRESULT hr = manager->Init(aKnowsCompositor, aFailureReason, aDevice);
HRESULT hr = manager->Init(aKnowsCompositor, aFailureReason);
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
return manager.forget();
@ -1183,16 +1024,14 @@ DXVA2Manager::CreateD3D11DXVA(layers::KnowsCompositor* aKnowsCompositor,
DXVA2Manager::DXVA2Manager()
: mLock("DXVA2Manager")
{
if (NS_IsMainThread()) {
++sDXVAVideosCount;
}
MOZ_ASSERT(NS_IsMainThread());
++sDXVAVideosCount;
}
DXVA2Manager::~DXVA2Manager()
{
if (NS_IsMainThread()) {
--sDXVAVideosCount;
}
MOZ_ASSERT(NS_IsMainThread());
--sDXVAVideosCount;
}
bool

Просмотреть файл

@ -31,8 +31,7 @@ public:
nsACString& aFailureReason);
static DXVA2Manager* CreateD3D11DXVA(
layers::KnowsCompositor* aKnowsCompositor,
nsACString& aFailureReason,
ID3D11Device* aDevice = nullptr);
nsACString& aFailureReason);
// Returns a pointer to the D3D device manager responsible for managing the
// device we're using for hardware accelerated video decoding. If we're using
@ -45,14 +44,6 @@ public:
const nsIntRect& aRegion,
layers::Image** aOutImage) = 0;
virtual HRESULT CopyToBGRATexture(ID3D11Texture2D *aInTexture,
ID3D11Texture2D** aOutTexture)
{
// Not implemented!
MOZ_CRASH("CopyToBGRATexture not implemented on this manager.");
return E_FAIL;
}
virtual HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight)
{
return S_OK;

Просмотреть файл

@ -12,9 +12,6 @@
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "d3d11.h"
#include "gfxPrefs.h"
#include "DXVA2Manager.h"
#include <memory>
namespace mozilla {
namespace layers {
@ -31,11 +28,7 @@ bool
D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice)
{
if (aAllocator) {
if (gfxPrefs::PDMWMFUseNV12Format()) {
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::NV12, mSize);
} else {
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
}
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
if (mTextureClient) {
mTexture = static_cast<D3D11TextureData*>(mTextureClient->GetInternalData())->GetD3D11Texture();
return true;
@ -80,30 +73,6 @@ D3D11ShareHandleImage::GetAsSourceSurface()
D3D11_TEXTURE2D_DESC desc;
texture->GetDesc(&desc);
HRESULT hr;
if (desc.Format == DXGI_FORMAT_NV12) {
nsAutoCString error;
std::unique_ptr<DXVA2Manager> manager(DXVA2Manager::CreateD3D11DXVA(nullptr, error, device));
if (!manager) {
gfxWarning() << "Failed to create DXVA2 manager!";
return nullptr;
}
RefPtr<ID3D11Texture2D> outTexture;
hr = manager->CopyToBGRATexture(texture, getter_AddRefs(outTexture));
if (FAILED(hr)) {
gfxWarning() << "Failed to copy NV12 to BGRA texture.";
return nullptr;
}
texture = outTexture;
texture->GetDesc(&desc);
}
CD3D11_TEXTURE2D_DESC softDesc(desc.Format, desc.Width, desc.Height);
softDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
softDesc.BindFlags = 0;
@ -112,7 +81,7 @@ D3D11ShareHandleImage::GetAsSourceSurface()
softDesc.Usage = D3D11_USAGE_STAGING;
RefPtr<ID3D11Texture2D> softTexture;
hr = device->CreateTexture2D(&softDesc,
HRESULT hr = device->CreateTexture2D(&softDesc,
NULL,
static_cast<ID3D11Texture2D**>(getter_AddRefs(softTexture)));
@ -192,16 +161,12 @@ already_AddRefed<TextureClient>
D3D11RecycleAllocator::CreateOrRecycleClient(gfx::SurfaceFormat aFormat,
const gfx::IntSize& aSize)
{
TextureAllocationFlags allocFlags = TextureAllocationFlags::ALLOC_DEFAULT;
if (gfxPrefs::PDMWMFUseSyncTexture()) {
allocFlags = TextureAllocationFlags::ALLOC_MANUAL_SYNCHRONIZATION;
}
RefPtr<TextureClient> textureClient =
CreateOrRecycle(aFormat,
aSize,
BackendSelector::Content,
layers::TextureFlags::DEFAULT,
allocFlags);
TextureAllocationFlags::ALLOC_DEFAULT);
return textureClient.forget();
}

Просмотреть файл

@ -1713,18 +1713,14 @@ UpdateYCbCrTextureClient(TextureClient* aTexture, const PlanarYCbCrData& aData)
}
already_AddRefed<SyncObject>
SyncObject::CreateSyncObject(SyncHandle aHandle
#ifdef XP_WIN
, ID3D11Device* aDevice
#endif
)
SyncObject::CreateSyncObject(SyncHandle aHandle)
{
if (!aHandle) {
return nullptr;
}
#ifdef XP_WIN
return MakeAndAddRef<SyncObjectD3D11>(aHandle, aDevice);
return MakeAndAddRef<SyncObjectD3D11>(aHandle);
#else
MOZ_ASSERT_UNREACHABLE();
return nullptr;

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsThreadUtils.h"
class gfxImageSurface;
struct ID3D11Device;
namespace mozilla {
@ -104,11 +103,7 @@ public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SyncObject)
virtual ~SyncObject() { }
static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle
#ifdef XP_WIN
, ID3D11Device* aDevice = nullptr
#endif
);
static already_AddRefed<SyncObject> CreateSyncObject(SyncHandle aHandle);
enum class SyncType {
D3D11,

Просмотреть файл

@ -11,7 +11,6 @@
#define PS_LAYER_RGBA 1
#define PS_LAYER_YCBCR 2
#define PS_LAYER_COLOR 3
#define PS_LAYER_NV12 4
// These must be in the same order as the Mask enum.
#define PS_MASK_NONE 0

Просмотреть файл

@ -107,7 +107,6 @@ struct DeviceAttachmentsD3D11
PixelShaderArray mRGBAShader;
PixelShaderArray mRGBShader;
PixelShaderArray mYCbCrShader;
PixelShaderArray mNV12Shader;
PixelShaderArray mComponentAlphaShader;
PixelShaderArray mBlendShader;
RefPtr<ID3D11Buffer> mPSConstantBuffer;
@ -767,8 +766,6 @@ CompositorD3D11::GetPSForEffect(Effect* aEffect,
? mAttachments->mRGBAShader[aMaskType]
: mAttachments->mRGBShader[aMaskType];
}
case EffectTypes::NV12:
return mAttachments->mNV12Shader[aMaskType];
case EffectTypes::YCBCR:
return mAttachments->mYCbCrShader[aMaskType];
case EffectTypes::COMPONENT_ALPHA:
@ -842,8 +839,6 @@ EffectToBlendLayerType(Effect* aEffect)
return PS_LAYER_RGBA;
case EffectTypes::YCBCR:
return PS_LAYER_YCBCR;
case EffectTypes::NV12:
return PS_LAYER_NV12;
default:
MOZ_ASSERT_UNREACHABLE("blending not supported for this layer type");
return 0;
@ -1105,45 +1100,6 @@ CompositorD3D11::DrawGeometry(const Geometry& aGeometry,
SetSamplerForSamplingFilter(texturedEffect->mSamplingFilter);
}
break;
case EffectTypes::NV12:
{
TexturedEffect* texturedEffect =
static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
pTexCoordRect = &texturedEffect->mTextureCoords;
TextureSourceD3D11* source = texturedEffect->mTexture->AsSourceD3D11();
if (!source) {
NS_WARNING("Missing texture source!");
return;
}
RefPtr<ID3D11Texture2D> texture = source->GetD3D11Texture();
if (!texture) {
NS_WARNING("No texture found in texture source!");
}
// Might want to cache these for efficiency.
RefPtr<ID3D11ShaderResourceView> srViewY;
RefPtr<ID3D11ShaderResourceView> srViewCbCr;
mDevice->CreateShaderResourceView(texture,
&CD3D11_SHADER_RESOURCE_VIEW_DESC(D3D11_SRV_DIMENSION_TEXTURE2D,
DXGI_FORMAT_R8_UNORM),
getter_AddRefs(srViewY));
mDevice->CreateShaderResourceView(texture,
&CD3D11_SHADER_RESOURCE_VIEW_DESC(D3D11_SRV_DIMENSION_TEXTURE2D,
DXGI_FORMAT_R8G8_UNORM),
getter_AddRefs(srViewCbCr));
ID3D11ShaderResourceView* views[] = { srViewY, srViewCbCr };
mContext->PSSetShaderResources(TexSlot::Y, 2, views);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x3RowMajor(YUVColorSpace::BT601);
memcpy(&mPSConstants.yuvColorMatrix, yuvToRgb, sizeof(mPSConstants.yuvColorMatrix));
SetSamplerForSamplingFilter(texturedEffect->mSamplingFilter);
}
break;
case EffectTypes::YCBCR: {
EffectYCbCr* ycbcrEffect =
static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
@ -1680,8 +1636,6 @@ DeviceAttachmentsD3D11::CreateShaders()
InitPixelShader(sRGBAShaderMask, mRGBAShader, MaskType::Mask);
InitPixelShader(sYCbCrShader, mYCbCrShader, MaskType::MaskNone);
InitPixelShader(sYCbCrShaderMask, mYCbCrShader, MaskType::Mask);
InitPixelShader(sNV12Shader, mNV12Shader, MaskType::MaskNone);
InitPixelShader(sNV12ShaderMask, mNV12Shader, MaskType::Mask);
if (gfxPrefs::ComponentAlphaEnabled()) {
InitPixelShader(sComponentAlphaShader, mComponentAlphaShader, MaskType::MaskNone);
InitPixelShader(sComponentAlphaShaderMask, mComponentAlphaShader, MaskType::Mask);

Просмотреть файл

@ -255,21 +255,6 @@ float4 CalculateYCbCrColor(const float2 aTexCoords)
return color;
}
float4 CalculateNV12Color(const float2 aTexCoords)
{
float3 yuv;
float4 color;
yuv.x = tY.Sample(sSampler, aTexCoords).r - 0.06275;
yuv.y = tCb.Sample(sSampler, aTexCoords).r - 0.50196;
yuv.z = tCb.Sample(sSampler, aTexCoords).g - 0.50196;
color.rgb = mul(mYuvColorMatrix, yuv);
color.a = 1.0f;
return color;
}
float4 YCbCrShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
@ -278,14 +263,6 @@ float4 YCbCrShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
return CalculateYCbCrColor(aVertex.vTexCoords) * fLayerOpacity * mask;
}
float4 NV12ShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
float mask = tMask.Sample(sSampler, maskCoords).r;
return CalculateNV12Color(aVertex.vTexCoords) * fLayerOpacity * mask;
}
PS_OUTPUT ComponentAlphaShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
{
PS_OUTPUT result;
@ -331,11 +308,6 @@ float4 YCbCrShader(const VS_OUTPUT aVertex) : SV_Target
return CalculateYCbCrColor(aVertex.vTexCoords) * fLayerOpacity;
}
float4 NV12Shader(const VS_OUTPUT aVertex) : SV_Target
{
return CalculateNV12Color(aVertex.vTexCoords) * fLayerOpacity;
}
PS_OUTPUT ComponentAlphaShader(const VS_OUTPUT aVertex) : SV_Target
{
PS_OUTPUT result;
@ -418,8 +390,6 @@ float4 ComputeBlendSourceColor(const VS_BLEND_OUTPUT aVertex)
return RGBAShader(tmp);
} else if (iBlendConfig.x == PS_LAYER_YCBCR) {
return YCbCrShader(tmp);
} else if (iBlendConfig.x == PS_LAYER_NV12) {
return NV12Shader(tmp);
}
return SolidColorShader(tmp);
} else if (iBlendConfig.y == PS_MASK) {
@ -434,8 +404,6 @@ float4 ComputeBlendSourceColor(const VS_BLEND_OUTPUT aVertex)
return RGBAShaderMask(tmp);
} else if (iBlendConfig.x == PS_LAYER_YCBCR) {
return YCbCrShaderMask(tmp);
} else if (iBlendConfig.x == PS_LAYER_NV12) {
return NV12ShaderMask(tmp);
}
return SolidColorShaderMask(tmp);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -337,8 +337,8 @@ DXGITextureData::FillInfo(TextureData::Info& aInfo) const
void
D3D11TextureData::SyncWithObject(SyncObject* aSyncObject)
{
if (!aSyncObject || mHasSynchronization) {
// When we have per texture synchronization we sync using the keyed mutex.
if (!aSyncObject || !NS_IsMainThread() || mIsForOutOfBandContent) {
// When off the main thread we sync using a keyed mutex per texture.
return;
}
@ -395,10 +395,6 @@ D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, SourceSurface* aS
aSize.width, aSize.height, 1, 1,
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE);
if (aFormat == SurfaceFormat::NV12) {
newDesc.Format = DXGI_FORMAT_NV12;
}
newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
if (!NS_IsMainThread() || !!(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT)) {
// On the main thread we use the syncobject to handle synchronization.
@ -1199,15 +1195,10 @@ CompositingRenderTargetD3D11::GetSize() const
return TextureSourceD3D11::GetSize();
}
SyncObjectD3D11::SyncObjectD3D11(SyncHandle aSyncHandle, ID3D11Device* aDevice)
SyncObjectD3D11::SyncObjectD3D11(SyncHandle aSyncHandle)
: mSyncHandle(aSyncHandle)
{
if (!aDevice) {
mD3D11Device = DeviceManagerDx::Get()->GetContentDevice();
return;
}
mD3D11Device = aDevice;
mD3D11Device = DeviceManagerDx::Get()->GetContentDevice();
}
bool
@ -1217,7 +1208,9 @@ SyncObjectD3D11::Init()
return true;
}
HRESULT hr = mD3D11Device->OpenSharedResource(
RefPtr<ID3D11Device> device = DeviceManagerDx::Get()->GetContentDevice();
HRESULT hr = device->OpenSharedResource(
mSyncHandle,
__uuidof(ID3D11Texture2D),
(void**)(ID3D11Texture2D**)getter_AddRefs(mD3D11Texture));
@ -1253,7 +1246,7 @@ bool
SyncObjectD3D11::IsSyncObjectValid()
{
RefPtr<ID3D11Device> dev = DeviceManagerDx::Get()->GetContentDevice();
if (!dev || (NS_IsMainThread() && dev != mD3D11Device)) {
if (!dev || (dev != mD3D11Device)) {
return false;
}
return true;
@ -1284,18 +1277,12 @@ SyncObjectD3D11::FinalizeFrame()
box.front = box.top = box.left = 0;
box.back = box.bottom = box.right = 1;
RefPtr<ID3D11Device> dev;
mD3D11Texture->GetDevice(getter_AddRefs(dev));
if (dev == DeviceManagerDx::Get()->GetContentDevice()) {
RefPtr<ID3D11Device> dev = DeviceManagerDx::Get()->GetContentDevice();
if (!dev) {
if (DeviceManagerDx::Get()->HasDeviceReset()) {
return;
}
}
if (dev != mD3D11Device) {
gfxWarning() << "Attempt to sync texture from invalid device.";
return;
MOZ_CRASH("GFX: Invalid D3D11 content device");
}
RefPtr<ID3D11DeviceContext> ctx;

Просмотреть файл

@ -413,7 +413,7 @@ private:
class SyncObjectD3D11 : public SyncObject
{
public:
explicit SyncObjectD3D11(SyncHandle aSyncHandle, ID3D11Device* aDevice);
explicit SyncObjectD3D11(SyncHandle aSyncHandle);
virtual void FinalizeFrame();
virtual bool IsSyncObjectValid();

Просмотреть файл

@ -36,14 +36,12 @@ makeShaderPS RGBShader
makeShaderPS RGBAShader
makeShaderPS ComponentAlphaShader
makeShaderPS YCbCrShader
makeShaderPS NV12Shader
makeShaderVS LayerQuadMaskVS
makeShaderVS LayerDynamicMaskVS
makeShaderPS SolidColorShaderMask
makeShaderPS RGBShaderMask
makeShaderPS RGBAShaderMask
makeShaderPS YCbCrShaderMask
makeShaderPS NV12ShaderMask
makeShaderPS ComponentAlphaShaderMask
# Mix-blend shaders

Просмотреть файл

@ -576,8 +576,6 @@ private:
#ifdef XP_WIN
DECL_GFX_PREF(Live, "media.windows-media-foundation.allow-d3d11-dxva", PDMWMFAllowD3D11, bool, true);
DECL_GFX_PREF(Live, "media.windows-media-foundation.max-dxva-videos", PDMWMFMaxDXVAVideos, uint32_t, 8);
DECL_GFX_PREF(Live, "media.windows-media-foundation.use-nv12-format", PDMWMFUseNV12Format, bool, true);
DECL_GFX_PREF(Once, "media.windows-media-foundation.use-sync-texture", PDMWMFUseSyncTexture, bool, true);
DECL_GFX_PREF(Live, "media.wmf.low-latency.enabled", PDMWMFLowLatencyEnabled, bool, false);
DECL_GFX_PREF(Live, "media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
#endif