mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 617220 - Add 3DVision stereoscopic rendering support to D3D10 layers. r=bas.schouten r=vlad a=roc a=vlad
This commit is contained in:
parent
44d1f1a0b6
commit
f766495afc
@ -40,6 +40,7 @@
|
||||
#include "gfxD2DSurface.h"
|
||||
#include "gfxWindowsSurface.h"
|
||||
#include "yuv_convert.h"
|
||||
#include "../d3d9/Nv3DVUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -303,6 +304,39 @@ ImageLayerD3D10::RenderLayer()
|
||||
effect()->GetVariableByName("tCb")->AsShaderResource()->SetResource(yuvImage->mCbView);
|
||||
effect()->GetVariableByName("tCr")->AsShaderResource()->SetResource(yuvImage->mCrView);
|
||||
|
||||
/*
|
||||
* Send 3d control data and metadata to NV3DVUtils
|
||||
*/
|
||||
if (GetNv3DVUtils()) {
|
||||
Nv_Stereo_Mode mode;
|
||||
switch (yuvImage->mData.mStereoMode) {
|
||||
case STEREO_MODE_LEFT_RIGHT:
|
||||
mode = NV_STEREO_MODE_LEFT_RIGHT;
|
||||
break;
|
||||
case STEREO_MODE_RIGHT_LEFT:
|
||||
mode = NV_STEREO_MODE_RIGHT_LEFT;
|
||||
break;
|
||||
case STEREO_MODE_BOTTOM_TOP:
|
||||
mode = NV_STEREO_MODE_BOTTOM_TOP;
|
||||
break;
|
||||
case STEREO_MODE_TOP_BOTTOM:
|
||||
mode = NV_STEREO_MODE_TOP_BOTTOM;
|
||||
break;
|
||||
case STEREO_MODE_MONO:
|
||||
mode = NV_STEREO_MODE_MONO;
|
||||
break;
|
||||
}
|
||||
|
||||
// Send control data even in mono case so driver knows to leave stereo mode.
|
||||
GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
|
||||
|
||||
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
|
||||
// Dst resource is optional
|
||||
GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->mSize.width,
|
||||
(unsigned int)yuvImage->mSize.height, (HANDLE)(yuvImage->mYTexture), (HANDLE)(NULL));
|
||||
}
|
||||
}
|
||||
|
||||
effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
|
||||
ShaderConstantRectD3D10(
|
||||
(float)0,
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "CanvasLayerD3D10.h"
|
||||
#include "ImageLayerD3D10.h"
|
||||
|
||||
#include "../d3d9/Nv3DVUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
@ -98,11 +100,35 @@ LayerManagerD3D10::Initialize()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
/* Create an Nv3DVUtils instance */
|
||||
if (!mNv3DVUtils) {
|
||||
mNv3DVUtils = new Nv3DVUtils();
|
||||
if (!mNv3DVUtils) {
|
||||
NS_WARNING("Could not create a new instance of Nv3DVUtils.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the Nv3DVUtils object */
|
||||
if (mNv3DVUtils) {
|
||||
mNv3DVUtils->Initialize();
|
||||
}
|
||||
|
||||
mDevice = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
|
||||
if (!mDevice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do some post device creation setup
|
||||
*/
|
||||
if (mNv3DVUtils) {
|
||||
IUnknown* devUnknown = NULL;
|
||||
if (mDevice) {
|
||||
mDevice->QueryInterface(IID_IUnknown, (void **)&devUnknown);
|
||||
}
|
||||
mNv3DVUtils->SetDeviceInfo(devUnknown);
|
||||
}
|
||||
|
||||
UINT size = sizeof(ID3D10Effect*);
|
||||
if (FAILED(mDevice->GetPrivateData(sEffect, &size, mEffect.StartAssignment()))) {
|
||||
D3D10CreateEffectFromMemoryFunc createEffect = (D3D10CreateEffectFromMemoryFunc)
|
||||
|
@ -49,6 +49,8 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class Nv3DVUtils;
|
||||
|
||||
/**
|
||||
* This structure is used to pass rectangles to our shader constant. We can use
|
||||
* this for passing rectangular areas to SetVertexShaderConstant. In the format
|
||||
@ -141,6 +143,11 @@ public:
|
||||
void SetViewport(const nsIntSize &aViewport);
|
||||
const nsIntSize &GetViewport() { return mViewport; }
|
||||
|
||||
/**
|
||||
* Return pointer to the Nv3DVUtils instance
|
||||
*/
|
||||
Nv3DVUtils *GetNv3DVUtils() { return mNv3DVUtils; }
|
||||
|
||||
static void LayerManagerD3D10::ReportFailure(const nsACString &aMsg, HRESULT aCode);
|
||||
|
||||
private:
|
||||
@ -166,6 +173,9 @@ private:
|
||||
|
||||
nsIntSize mViewport;
|
||||
|
||||
/* Nv3DVUtils instance */
|
||||
nsAutoPtr<Nv3DVUtils> mNv3DVUtils;
|
||||
|
||||
/*
|
||||
* Context target, NULL when drawing directly to our swap chain.
|
||||
*/
|
||||
@ -204,6 +214,12 @@ public:
|
||||
/* Called by the layer manager when it's destroyed */
|
||||
virtual void LayerManagerDestroyed() {}
|
||||
|
||||
/**
|
||||
* Return pointer to the Nv3DVUtils instance. Calls equivalent method in LayerManager.
|
||||
*/
|
||||
Nv3DVUtils *GetNv3DVUtils() { return mD3DManager->GetNv3DVUtils(); }
|
||||
|
||||
|
||||
void SetEffectTransformAndOpacity()
|
||||
{
|
||||
Layer* layer = GetLayer();
|
||||
|
@ -283,7 +283,10 @@ ImageLayerD3D9::RenderLayer()
|
||||
|
||||
mD3DManager->SetShaderMode(DeviceManagerD3D9::YCBCRLAYER);
|
||||
|
||||
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
|
||||
/*
|
||||
* Send 3d control data and metadata
|
||||
*/
|
||||
if (mD3DManager->GetNv3DVUtils()) {
|
||||
Nv_Stereo_Mode mode;
|
||||
switch (yuvImage->mData.mStereoMode) {
|
||||
case STEREO_MODE_LEFT_RIGHT:
|
||||
@ -298,12 +301,15 @@ ImageLayerD3D9::RenderLayer()
|
||||
case STEREO_MODE_TOP_BOTTOM:
|
||||
mode = NV_STEREO_MODE_TOP_BOTTOM;
|
||||
break;
|
||||
case STEREO_MODE_MONO:
|
||||
mode = NV_STEREO_MODE_MONO;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send 3d control data and metadata
|
||||
*/
|
||||
if (mD3DManager->GetNv3DVUtils()) {
|
||||
// Send control data even in mono case so driver knows to leave stereo mode.
|
||||
mD3DManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
|
||||
|
||||
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
|
||||
mD3DManager->GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
|
||||
|
||||
nsRefPtr<IDirect3DSurface9> renderTarget;
|
||||
|
@ -52,7 +52,8 @@ enum Nv_Stereo_Mode {
|
||||
NV_STEREO_MODE_RIGHT_LEFT = 1,
|
||||
NV_STEREO_MODE_TOP_BOTTOM = 2,
|
||||
NV_STEREO_MODE_BOTTOM_TOP = 3,
|
||||
NV_STEREO_MODE_LAST = 4
|
||||
NV_STEREO_MODE_MONO = 4,
|
||||
NV_STEREO_MODE_LAST = 5
|
||||
};
|
||||
|
||||
class INv3DVStreaming : public IUnknown {
|
||||
|
Loading…
Reference in New Issue
Block a user