Basic port of code

This commit is contained in:
James Urquhart 2016-03-21 15:10:14 +00:00
parent 93a36f006f
commit 64b751a7c8
19 changed files with 613 additions and 374 deletions

View file

@ -128,6 +128,9 @@ void GFXD3D11Device::enumerateAdapters(Vector<GFXAdapter*> &adapterList)
DXGI_ADAPTER_DESC1 desc;
EnumAdapter->GetDesc1(&desc);
// LUID identifies adapter for oculus rift
dMemcpy(&toAdd->mLUID, &desc.AdapterLuid, sizeof(toAdd->mLUID));
size_t size=wcslen(desc.Description);
char *str = new char[size+1];

View file

@ -42,6 +42,8 @@
class PlatformWindow;
class GFXD3D11ShaderConstBuffer;
class OculusVRHMDDevice;
class D3D11OculusTexture;
//------------------------------------------------------------------------------
@ -53,6 +55,8 @@ class GFXD3D11Device : public GFXDevice
friend class GFXD3D11TextureObject;
friend class GFXD3D11TextureTarget;
friend class GFXD3D11WindowTarget;
friend class OculusVRHMDDevice;
friend class D3D11OculusTexture;
virtual GFXFormat selectSupportedFormat(GFXTextureProfile *profile,
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter);

View file

@ -163,6 +163,13 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
mTargetSize = Point2I(sd.Width, sd.Height);
S32 format = sd.Format;
if (format == DXGI_FORMAT_R8G8B8A8_TYPELESS || format == DXGI_FORMAT_B8G8R8A8_TYPELESS)
{
mTargetFormat = GFXFormatR8G8B8A8;
return;
}
GFXREVERSE_LOOKUP( GFXD3D11TextureFormat, GFXFormat, format );
mTargetFormat = (GFXFormat)format;
}

View file

@ -67,6 +67,12 @@ GFXLockedRect *GFXD3D11TextureObject::lock(U32 mipLevel /*= 0*/, RectI *inRect /
D3D11_MAPPED_SUBRESOURCE mapInfo;
/*if (!mProfile->canModify())
{
AssertFatal(false, "Tried to modify external texture");
return NULL;
}*/
if( mProfile->isRenderTarget() )
{
//AssertFatal( 0, "GFXD3D11TextureObject::lock - Need to handle mapping render targets" );

View file

@ -35,6 +35,12 @@
#include "core/util/delegate.h"
#endif
struct GFXAdapterLUID
{
unsigned long LowPart;
long HighPart;
};
struct GFXAdapter
{
public:
@ -58,6 +64,9 @@ public:
/// Supported shader model. 0.f means none supported.
F32 mShaderModel;
/// LUID for windows oculus support
GFXAdapterLUID mLUID;
const char * getName() const { return mName; }
const char * getOutputName() const { return mOutputName; }
GFXAdapterType mType;
@ -72,6 +81,7 @@ public:
mOutputName[0] = 0;
mShaderModel = 0.f;
mIndex = 0;
dMemset(&mLUID, '\0', sizeof(mLUID));
}
~GFXAdapter()

View file

@ -198,6 +198,22 @@ GFXAdapter* GFXInit::getAdapterOfType( GFXAdapterType type, const char* outputDe
return NULL;
}
GFXAdapter* GFXInit::getAdapterOfType(GFXAdapterType type, S32 outputDeviceIndex)
{
for (U32 i = 0; i < smAdapters.size(); i++)
{
if (smAdapters[i]->mType == type)
{
if (smAdapters[i]->mIndex == outputDeviceIndex)
{
return smAdapters[i];
}
}
}
return NULL;
}
GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevice)
{
GFXAdapter* adapter = GFXInit::getAdapterOfType(type, outputDevice);
@ -219,6 +235,27 @@ GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevic
return adapter;
}
GFXAdapter* GFXInit::chooseAdapter(GFXAdapterType type, S32 outputDeviceIndex)
{
GFXAdapter* adapter = GFXInit::getAdapterOfType(type, outputDeviceIndex);
if (!adapter && type != OpenGL)
{
Con::errorf("The requested renderer, %s, doesn't seem to be available."
" Trying the default, OpenGL.", getAdapterNameFromType(type));
adapter = GFXInit::getAdapterOfType(OpenGL, outputDeviceIndex);
}
if (!adapter)
{
Con::errorf("The OpenGL renderer doesn't seem to be available. Trying the GFXNulDevice.");
adapter = GFXInit::getAdapterOfType(NullDevice, 0);
}
AssertFatal(adapter, "There is no rendering device available whatsoever.");
return adapter;
}
const char* GFXInit::getAdapterNameFromType(GFXAdapterType type)
{
// must match GFXAdapterType order
@ -256,8 +293,19 @@ GFXAdapter *GFXInit::getBestAdapterChoice()
// Get the user's preference for device...
const String renderer = Con::getVariable("$pref::Video::displayDevice");
const String outputDevice = Con::getVariable("$pref::Video::displayOutputDevice");
GFXAdapterType adapterType = getAdapterTypeFromName(renderer.c_str());
GFXAdapter *adapter = chooseAdapter(adapterType, outputDevice.c_str());
const String adapterDevice = Con::getVariable("$Video::forceDisplayAdapter");
GFXAdapterType adapterType = getAdapterTypeFromName(renderer.c_str());;
GFXAdapter *adapter;
if (adapterDevice.isEmpty())
{
adapter = chooseAdapter(adapterType, outputDevice.c_str());
}
else
{
adapter = chooseAdapter(adapterType, dAtoi(adapterDevice.c_str()));
}
// Did they have one? Return it.
if(adapter)

View file

@ -74,10 +74,16 @@ public:
/// This method never returns NULL.
static GFXAdapter *chooseAdapter( GFXAdapterType type, const char* outputDevice);
/// Override which chooses an adapter based on an index instead
static GFXAdapter *chooseAdapter( GFXAdapterType type, S32 outputDeviceIndex );
/// Gets the first adapter of the requested type (and on the requested output device)
/// from the list of enumerated adapters. Should only call this after a call to
/// enumerateAdapters.
static GFXAdapter *getAdapterOfType( GFXAdapterType type, const char* outputDevice );
/// Override which gets an adapter based on an index instead
static GFXAdapter *getAdapterOfType( GFXAdapterType type, S32 outputDeviceIndex );
/// Converts a GFXAdapterType to a string name. Useful for writing out prefs
static const char *getAdapterNameFromType( GFXAdapterType type );

View file

@ -100,7 +100,10 @@ public:
/// of a target texture after presentation or deactivated.
///
/// This is mainly a depth buffer optimization.
NoDiscard = BIT(10)
NoDiscard = BIT(10),
/// Texture is managed by another process, thus should not be modified
NoModify = BIT(11)
};
@ -164,6 +167,7 @@ public:
inline bool noMip() const { return testFlag(NoMipmap); }
inline bool isPooled() const { return testFlag(Pooled); }
inline bool canDiscard() const { return !testFlag(NoDiscard); }
inline bool canModify() const { return !testFlag(NoModify); }
private:
/// These constants control the packing for the profile; if you add flags, types, or