mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
Tidy up indentation in openvr changes
This commit is contained in:
parent
e6159a590a
commit
212ac36cc1
25 changed files with 2171 additions and 2172 deletions
|
|
@ -36,17 +36,17 @@ void ExtendedMoveManager::init()
|
|||
dSprintf(varName, sizeof(varName), "mvPosX%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mPosX[i],
|
||||
"X position of controller in millimeters. Only 13 bits are networked.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvPosY%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mPosY[i],
|
||||
"Y position of controller in millimeters. Only 13 bits are networked.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvPosZ%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mPosZ[i],
|
||||
"Z position of controller in millimeters. Only 13 bits are networked.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotIsEuler%d", i);
|
||||
Con::addVariable(varName, TypeBool, &mRotIsEuler[i],
|
||||
|
|
@ -55,33 +55,33 @@ void ExtendedMoveManager::init()
|
|||
"(a vector and angle). When true, the given rotation is a three component "
|
||||
"Euler angle. When using Euler angles, the $mvRotA component of the ExtendedMove "
|
||||
"is ignored for this set of rotations.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotX%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mRotAX[i],
|
||||
"X rotation vector component of controller.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotY%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mRotAY[i],
|
||||
"Y rotation vector component of controller.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotZ%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mRotAZ[i],
|
||||
"Z rotation vector component of controller.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
|
||||
dSprintf(varName, sizeof(varName), "mvRotA%d", i);
|
||||
Con::addVariable(varName, TypeF32, &mRotAA[i],
|
||||
"Angle rotation (in degrees) component of controller.\n"
|
||||
"@ingroup Game");
|
||||
"@ingroup Game");
|
||||
}
|
||||
|
||||
Con::addVariable("mvPosScale", TypeF32, &mPosScale,
|
||||
"@brief Indicates the scale to be given to mvPos values.\n\n"
|
||||
""
|
||||
"@ingroup Game");
|
||||
"@brief Indicates the scale to be given to mvPos values.\n\n"
|
||||
""
|
||||
"@ingroup Game");
|
||||
}
|
||||
|
||||
const ExtendedMove NullExtendedMove;
|
||||
|
|
@ -293,7 +293,7 @@ void ExtendedMove::clamp()
|
|||
crotW[i] = CLAMPROT(rotW[i] / M_2PI_F);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CONTROLLER_MOVE
|
||||
#ifdef DEBUG_CONTROLLER_MOVE
|
||||
if (i == 1)
|
||||
{
|
||||
F32 x, y, z, a;
|
||||
|
|
@ -302,14 +302,14 @@ void ExtendedMove::clamp()
|
|||
z = UNCLAMPPOS(crotZ[i]);
|
||||
a = UNCLAMPROT(crotW[i]) * M_2PI_F;
|
||||
|
||||
Con::printf("INPUT POS == %f,%f,%f", ExtendedMoveManager::mPosX[i], ExtendedMoveManager::mPosY[i], ExtendedMoveManager::mPosZ[i]);
|
||||
Con::printf("INPUT POS == %f,%f,%f", ExtendedMoveManager::mPosX[i], ExtendedMoveManager::mPosY[i], ExtendedMoveManager::mPosZ[i]);
|
||||
Con::printf("rot %f,%f,%f,%f clamped to %f,%f,%f,%f", rotX[i], rotY[i], rotZ[i], rotW[i], x,y,z,a);
|
||||
x = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
y = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
z = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
Con::printf("pos %f,%f,%f clamped to %f,%f,%f", posX[i], posY[i], posZ[i], x, y, z);
|
||||
x = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
y = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
z = UNCLAMPPOS(cposX[i]) * ExtendedMoveManager::mPosScale;
|
||||
Con::printf("pos %f,%f,%f clamped to %f,%f,%f", posX[i], posY[i], posZ[i], x, y, z);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Perform the standard Move clamp
|
||||
|
|
|
|||
|
|
@ -469,8 +469,8 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
|
|||
|
||||
for(U32 i = 0; i < mConnectArgc+3; i++)
|
||||
{
|
||||
connectArgv[i].value = &connectArgvValue[i];
|
||||
connectArgvValue[i].init();
|
||||
connectArgv[i].value = &connectArgvValue[i];
|
||||
connectArgvValue[i].init();
|
||||
}
|
||||
|
||||
for(U32 i = 0; i < mConnectArgc; i++)
|
||||
|
|
@ -683,20 +683,20 @@ bool GameConnection::getControlCameraTransform(F32 dt, MatrixF* mat)
|
|||
|
||||
bool GameConnection::getControlCameraHeadTransform(IDisplayDevice *display, MatrixF *transform)
|
||||
{
|
||||
GameBase* obj = getCameraObject();
|
||||
if (!obj)
|
||||
return false;
|
||||
GameBase* obj = getCameraObject();
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
GameBase* cObj = obj;
|
||||
while ((cObj = cObj->getControlObject()) != 0)
|
||||
{
|
||||
if (cObj->useObjsEyePoint())
|
||||
obj = cObj;
|
||||
}
|
||||
GameBase* cObj = obj;
|
||||
while ((cObj = cObj->getControlObject()) != 0)
|
||||
{
|
||||
if (cObj->useObjsEyePoint())
|
||||
obj = cObj;
|
||||
}
|
||||
|
||||
obj->getEyeCameraTransform(display, -1, transform);
|
||||
obj->getEyeCameraTransform(display, -1, transform);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameConnection::getControlCameraEyeTransforms(IDisplayDevice *display, MatrixF *transforms)
|
||||
|
|
@ -914,8 +914,8 @@ void GameConnection::onRemove()
|
|||
// clientgroup and what not (this is so that we can disconnect from a local server
|
||||
// without needing to destroy and recreate the server before we can connect to it
|
||||
// again).
|
||||
// Safe-delete as we don't know whether the server connection is currently being
|
||||
// worked on.
|
||||
// Safe-delete as we don't know whether the server connection is currently being
|
||||
// worked on.
|
||||
getRemoteConnection()->safeDeleteObject();
|
||||
setRemoteConnectionObject(NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1783,7 +1783,7 @@ void Player::onRemove()
|
|||
mWorkingQueryBox.minExtents.set(-1e9f, -1e9f, -1e9f);
|
||||
mWorkingQueryBox.maxExtents.set(-1e9f, -1e9f, -1e9f);
|
||||
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
|
@ -2505,12 +2505,12 @@ void Player::updateMove(const Move* move)
|
|||
#ifdef TORQUE_OPENVR
|
||||
if (mControllers[0])
|
||||
{
|
||||
mControllers[0]->processTick(move);
|
||||
mControllers[0]->processTick(move);
|
||||
}
|
||||
|
||||
if (mControllers[1])
|
||||
{
|
||||
mControllers[1]->processTick(move);
|
||||
mControllers[1]->processTick(move);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -3337,9 +3337,9 @@ bool Player::canCrouch()
|
|||
if ( mDataBlock->actionList[PlayerData::CrouchRootAnim].sequence == -1 )
|
||||
return false;
|
||||
|
||||
// We are already in this pose, so don't test it again...
|
||||
if ( mPose == CrouchPose )
|
||||
return true;
|
||||
// We are already in this pose, so don't test it again...
|
||||
if ( mPose == CrouchPose )
|
||||
return true;
|
||||
|
||||
// Do standard Torque physics test here!
|
||||
if ( !mPhysicsRep )
|
||||
|
|
@ -3389,8 +3389,8 @@ bool Player::canStand()
|
|||
return false;
|
||||
|
||||
// We are already in this pose, so don't test it again...
|
||||
if ( mPose == StandPose )
|
||||
return true;
|
||||
if ( mPose == StandPose )
|
||||
return true;
|
||||
|
||||
// Do standard Torque physics test here!
|
||||
if ( !mPhysicsRep )
|
||||
|
|
@ -3453,9 +3453,9 @@ bool Player::canProne()
|
|||
if ( !mPhysicsRep )
|
||||
return true;
|
||||
|
||||
// We are already in this pose, so don't test it again...
|
||||
if ( mPose == PronePose )
|
||||
return true;
|
||||
// We are already in this pose, so don't test it again...
|
||||
if ( mPose == PronePose )
|
||||
return true;
|
||||
|
||||
return mPhysicsRep->testSpacials( getPosition(), mDataBlock->proneBoxSize );
|
||||
}
|
||||
|
|
@ -3652,7 +3652,7 @@ MatrixF * Player::Death::fallToGround(F32 dt, const Point3F& loc, F32 curZ, F32
|
|||
normal.normalize();
|
||||
mat.set(EulerF (0.0f, 0.0f, curZ));
|
||||
mat.mulV(upY, & ahead);
|
||||
mCross(ahead, normal, &sideVec);
|
||||
mCross(ahead, normal, &sideVec);
|
||||
sideVec.normalize();
|
||||
mCross(normal, sideVec, &ahead);
|
||||
|
||||
|
|
@ -5846,7 +5846,7 @@ F32 Player::getSpeed() const
|
|||
|
||||
void Player::setVelocity(const VectorF& vel)
|
||||
{
|
||||
AssertFatal( !mIsNaN( vel ), "Player::setVelocity() - The velocity is NaN!" );
|
||||
AssertFatal( !mIsNaN( vel ), "Player::setVelocity() - The velocity is NaN!" );
|
||||
|
||||
mVelocity = vel;
|
||||
setMaskBits(MoveMask);
|
||||
|
|
@ -5854,7 +5854,7 @@ void Player::setVelocity(const VectorF& vel)
|
|||
|
||||
void Player::applyImpulse(const Point3F&,const VectorF& vec)
|
||||
{
|
||||
AssertFatal( !mIsNaN( vec ), "Player::applyImpulse() - The vector is NaN!" );
|
||||
AssertFatal( !mIsNaN( vec ), "Player::applyImpulse() - The vector is NaN!" );
|
||||
|
||||
// Players ignore angular velocity
|
||||
VectorF vel;
|
||||
|
|
@ -6202,7 +6202,7 @@ U32 Player::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
stream->writeFlag(mSwimming);
|
||||
stream->writeFlag(mJetting);
|
||||
stream->writeInt(mPose, NumPoseBits);
|
||||
|
||||
|
||||
stream->writeInt(mState,NumStateBits);
|
||||
if (stream->writeFlag(mState == RecoverState))
|
||||
stream->writeInt(mRecoverTicks,PlayerData::RecoverDelayBits);
|
||||
|
|
@ -6303,7 +6303,7 @@ void Player::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
mSwimming = stream->readFlag();
|
||||
mJetting = stream->readFlag();
|
||||
mPose = (Pose)(stream->readInt(NumPoseBits));
|
||||
|
||||
|
||||
ActionState actionState = (ActionState)stream->readInt(NumStateBits);
|
||||
if (stream->readFlag()) {
|
||||
mRecoverTicks = stream->readInt(PlayerData::RecoverDelayBits);
|
||||
|
|
@ -7174,34 +7174,34 @@ void Player::renderConvex( ObjectRenderInst *ri, SceneRenderState *state, BaseMa
|
|||
#ifdef TORQUE_OPENVR
|
||||
void Player::setControllers(Vector<OpenVRTrackedObject*> controllerList)
|
||||
{
|
||||
mControllers[0] = controllerList.size() > 0 ? controllerList[0] : NULL;
|
||||
mControllers[1] = controllerList.size() > 1 ? controllerList[1] : NULL;
|
||||
mControllers[0] = controllerList.size() > 0 ? controllerList[0] : NULL;
|
||||
mControllers[1] = controllerList.size() > 1 ? controllerList[1] : NULL;
|
||||
}
|
||||
|
||||
ConsoleMethod(Player, setVRControllers, void, 4, 4, "")
|
||||
{
|
||||
OpenVRTrackedObject *controllerL, *controllerR;
|
||||
Vector<OpenVRTrackedObject*> list;
|
||||
OpenVRTrackedObject *controllerL, *controllerR;
|
||||
Vector<OpenVRTrackedObject*> list;
|
||||
|
||||
if (Sim::findObject(argv[2], controllerL))
|
||||
{
|
||||
list.push_back(controllerL);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.push_back(NULL);
|
||||
}
|
||||
if (Sim::findObject(argv[2], controllerL))
|
||||
{
|
||||
list.push_back(controllerL);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.push_back(NULL);
|
||||
}
|
||||
|
||||
if (Sim::findObject(argv[3], controllerR))
|
||||
{
|
||||
list.push_back(controllerR);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.push_back(NULL);
|
||||
}
|
||||
if (Sim::findObject(argv[3], controllerR))
|
||||
{
|
||||
list.push_back(controllerR);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.push_back(NULL);
|
||||
}
|
||||
|
||||
object->setControllers(list);
|
||||
object->setControllers(list);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -119,77 +119,77 @@ void GFXD3D11Device::enumerateAdapters(Vector<GFXAdapter*> &adapterList)
|
|||
|
||||
for(U32 adapterIndex = 0; DXGIFactory->EnumAdapters1(adapterIndex, &EnumAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
||||
{
|
||||
GFXAdapter *toAdd = new GFXAdapter;
|
||||
toAdd->mType = Direct3D11;
|
||||
toAdd->mIndex = adapterIndex;
|
||||
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
|
||||
GFXAdapter *toAdd = new GFXAdapter;
|
||||
toAdd->mType = Direct3D11;
|
||||
toAdd->mIndex = adapterIndex;
|
||||
toAdd->mCreateDeviceInstanceDelegate = mCreateDeviceInstance;
|
||||
|
||||
toAdd->mShaderModel = 5.0f;
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
EnumAdapter->GetDesc1(&desc);
|
||||
toAdd->mShaderModel = 5.0f;
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
EnumAdapter->GetDesc1(&desc);
|
||||
|
||||
// LUID identifies adapter for oculus rift
|
||||
dMemcpy(&toAdd->mLUID, &desc.AdapterLuid, sizeof(toAdd->mLUID));
|
||||
// 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];
|
||||
size_t size=wcslen(desc.Description);
|
||||
char *str = new char[size+1];
|
||||
|
||||
wcstombs(str, desc.Description,size);
|
||||
str[size]='\0';
|
||||
String Description=str;
|
||||
wcstombs(str, desc.Description,size);
|
||||
str[size]='\0';
|
||||
String Description=str;
|
||||
SAFE_DELETE_ARRAY(str);
|
||||
|
||||
dStrncpy(toAdd->mName, Description.c_str(), GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncat(toAdd->mName, " (D3D11)", GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncpy(toAdd->mName, Description.c_str(), GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncat(toAdd->mName, " (D3D11)", GFXAdapter::MaxAdapterNameLen);
|
||||
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
HRESULT hr;
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> EnumOutputs call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> EnumOutputs call failure");
|
||||
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateAdapters -> GetDisplayModeList call failure");
|
||||
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode vmAdd;
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode vmAdd;
|
||||
|
||||
vmAdd.fullScreen = true;
|
||||
vmAdd.bitDepth = 32;
|
||||
vmAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
vmAdd.resolution.x = displayModes[numMode].Width;
|
||||
vmAdd.resolution.y = displayModes[numMode].Height;
|
||||
toAdd->mAvailableModes.push_back(vmAdd);
|
||||
}
|
||||
vmAdd.fullScreen = true;
|
||||
vmAdd.bitDepth = 32;
|
||||
vmAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
vmAdd.resolution.x = displayModes[numMode].Width;
|
||||
vmAdd.resolution.y = displayModes[numMode].Height;
|
||||
toAdd->mAvailableModes.push_back(vmAdd);
|
||||
}
|
||||
|
||||
delete[] displayModes;
|
||||
delete[] displayModes;
|
||||
SAFE_RELEASE(pOutput);
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
adapterList.push_back(toAdd);
|
||||
adapterList.push_back(toAdd);
|
||||
}
|
||||
|
||||
SAFE_RELEASE(DXGIFactory);
|
||||
|
|
@ -210,50 +210,50 @@ void GFXD3D11Device::enumerateVideoModes()
|
|||
|
||||
for(U32 adapterIndex = 0; DXGIFactory->EnumAdapters1(adapterIndex, &EnumAdapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex)
|
||||
{
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
IDXGIOutput* pOutput = NULL;
|
||||
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
hr = EnumAdapter->EnumOutputs(adapterIndex, &pOutput);
|
||||
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
if(hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> EnumOutputs call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> EnumOutputs call failure");
|
||||
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = GFXD3D11TextureFormat[GFXFormatR8G8B8A8];
|
||||
UINT numModes = 0;
|
||||
DXGI_MODE_DESC* displayModes = NULL;
|
||||
DXGI_FORMAT format = GFXD3D11TextureFormat[GFXFormatR8G8B8A8];
|
||||
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
// Get the number of elements
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, NULL);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
displayModes = new DXGI_MODE_DESC[numModes];
|
||||
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
// Get the list
|
||||
hr = pOutput->GetDisplayModeList(format, 0, &numModes, displayModes);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::enumerateVideoModes -> GetDisplayModeList call failure");
|
||||
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode toAdd;
|
||||
for(U32 numMode = 0; numMode < numModes; ++numMode)
|
||||
{
|
||||
GFXVideoMode toAdd;
|
||||
|
||||
toAdd.fullScreen = false;
|
||||
toAdd.bitDepth = 32;
|
||||
toAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
toAdd.resolution.x = displayModes[numMode].Width;
|
||||
toAdd.resolution.y = displayModes[numMode].Height;
|
||||
mVideoModes.push_back(toAdd);
|
||||
}
|
||||
toAdd.fullScreen = false;
|
||||
toAdd.bitDepth = 32;
|
||||
toAdd.refreshRate = displayModes[numMode].RefreshRate.Numerator / displayModes[numMode].RefreshRate.Denominator;
|
||||
toAdd.resolution.x = displayModes[numMode].Width;
|
||||
toAdd.resolution.y = displayModes[numMode].Height;
|
||||
mVideoModes.push_back(toAdd);
|
||||
}
|
||||
|
||||
delete[] displayModes;
|
||||
delete[] displayModes;
|
||||
SAFE_RELEASE(pOutput);
|
||||
SAFE_RELEASE(EnumAdapter);
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ void GFXD3D11Device::enumerateVideoModes()
|
|||
|
||||
IDXGISwapChain* GFXD3D11Device::getSwapChain()
|
||||
{
|
||||
return mSwapChain;
|
||||
return mSwapChain;
|
||||
}
|
||||
|
||||
void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
||||
|
|
@ -285,19 +285,19 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
// create a device, device context and swap chain using the information in the d3dpp struct
|
||||
HRESULT hres = D3D11CreateDeviceAndSwapChain(NULL,
|
||||
driverType,
|
||||
NULL,
|
||||
createDeviceFlags,
|
||||
NULL,
|
||||
0,
|
||||
D3D11_SDK_VERSION,
|
||||
&d3dpp,
|
||||
&mSwapChain,
|
||||
&mD3DDevice,
|
||||
&deviceFeature,
|
||||
&mD3DDeviceContext);
|
||||
NULL,
|
||||
createDeviceFlags,
|
||||
NULL,
|
||||
0,
|
||||
D3D11_SDK_VERSION,
|
||||
&d3dpp,
|
||||
&mSwapChain,
|
||||
&mD3DDevice,
|
||||
&deviceFeature,
|
||||
&mD3DDeviceContext);
|
||||
|
||||
if(FAILED(hres))
|
||||
{
|
||||
if(FAILED(hres))
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
//try again without debug device layer enabled
|
||||
createDeviceFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
|
||||
|
|
@ -315,9 +315,9 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
Con::warnf("GFXD3D11Device::init - Debug layers not detected!");
|
||||
mDebugLayers = false;
|
||||
#else
|
||||
AssertFatal(false, "GFXD3D11Device::init - D3D11CreateDeviceAndSwapChain failed!");
|
||||
AssertFatal(false, "GFXD3D11Device::init - D3D11CreateDeviceAndSwapChain failed!");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//set the fullscreen state here if we need to
|
||||
if(mode.fullScreen)
|
||||
|
|
@ -329,79 +329,79 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
}
|
||||
}
|
||||
|
||||
mTextureManager = new GFXD3D11TextureManager();
|
||||
mTextureManager = new GFXD3D11TextureManager();
|
||||
|
||||
// Now reacquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
// Now reacquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
//TODO implement feature levels?
|
||||
if (deviceFeature >= D3D_FEATURE_LEVEL_11_0)
|
||||
mPixVersion = 5.0f;
|
||||
else
|
||||
AssertFatal(false, "GFXD3D11Device::init - We don't support anything below feature level 11.");
|
||||
if (deviceFeature >= D3D_FEATURE_LEVEL_11_0)
|
||||
mPixVersion = 5.0f;
|
||||
else
|
||||
AssertFatal(false, "GFXD3D11Device::init - We don't support anything below feature level 11.");
|
||||
|
||||
D3D11_QUERY_DESC queryDesc;
|
||||
D3D11_QUERY_DESC queryDesc;
|
||||
queryDesc.Query = D3D11_QUERY_OCCLUSION;
|
||||
queryDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Query *testQuery = NULL;
|
||||
ID3D11Query *testQuery = NULL;
|
||||
|
||||
// detect occlusion query support
|
||||
if (SUCCEEDED(mD3DDevice->CreateQuery(&queryDesc, &testQuery))) mOcclusionQuerySupported = true;
|
||||
// detect occlusion query support
|
||||
if (SUCCEEDED(mD3DDevice->CreateQuery(&queryDesc, &testQuery))) mOcclusionQuerySupported = true;
|
||||
|
||||
SAFE_RELEASE(testQuery);
|
||||
|
||||
Con::printf("Hardware occlusion query detected: %s", mOcclusionQuerySupported ? "Yes" : "No");
|
||||
Con::printf("Hardware occlusion query detected: %s", mOcclusionQuerySupported ? "Yes" : "No");
|
||||
|
||||
mCardProfiler = new GFXD3D11CardProfiler();
|
||||
mCardProfiler->init();
|
||||
mCardProfiler = new GFXD3D11CardProfiler();
|
||||
mCardProfiler->init();
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = mode.resolution.x;
|
||||
desc.Height = mode.resolution.y;
|
||||
desc.SampleDesc.Count =1;
|
||||
desc.SampleDesc.Quality =0;
|
||||
desc.MiscFlags = 0;
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = mode.resolution.x;
|
||||
desc.Height = mode.resolution.y;
|
||||
desc.SampleDesc.Count =1;
|
||||
desc.SampleDesc.Quality =0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
HRESULT hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
HRESULT hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags =0 ;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags =0 ;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create depth stencil view");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create depth stencil view");
|
||||
}
|
||||
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - coudln't retrieve backbuffer ref");
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - coudln't retrieve backbuffer ref");
|
||||
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create back buffer target view");
|
||||
if(FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::init - couldn't create back buffer target view");
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
String backBufferName = "MainBackBuffer";
|
||||
|
|
@ -419,8 +419,8 @@ void GFXD3D11Device::init(const GFXVideoMode &mode, PlatformWindow *window)
|
|||
|
||||
gScreenShot = new ScreenShotD3D11;
|
||||
|
||||
mInitialized = true;
|
||||
deviceInited();
|
||||
mInitialized = true;
|
||||
deviceInited();
|
||||
}
|
||||
|
||||
// Supress any debug layer messages we don't want to see
|
||||
|
|
@ -489,28 +489,28 @@ GFXTextureTarget* GFXD3D11Device::allocRenderToTextureTarget()
|
|||
|
||||
void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
||||
{
|
||||
if (!mD3DDevice)
|
||||
return;
|
||||
if (!mD3DDevice)
|
||||
return;
|
||||
|
||||
mInitialized = false;
|
||||
mInitialized = false;
|
||||
|
||||
// Clean up some commonly dangling state. This helps prevents issues with
|
||||
// items that are destroyed by the texture manager callbacks and recreated
|
||||
// later, but still left bound.
|
||||
setVertexBuffer(NULL);
|
||||
setPrimitiveBuffer(NULL);
|
||||
for (S32 i = 0; i<getNumSamplers(); i++)
|
||||
setTexture(i, NULL);
|
||||
// Clean up some commonly dangling state. This helps prevents issues with
|
||||
// items that are destroyed by the texture manager callbacks and recreated
|
||||
// later, but still left bound.
|
||||
setVertexBuffer(NULL);
|
||||
setPrimitiveBuffer(NULL);
|
||||
for (S32 i = 0; i<getNumSamplers(); i++)
|
||||
setTexture(i, NULL);
|
||||
|
||||
mD3DDeviceContext->ClearState();
|
||||
mD3DDeviceContext->ClearState();
|
||||
|
||||
DXGI_MODE_DESC displayModes;
|
||||
displayModes.Format = d3dpp.BufferDesc.Format;
|
||||
displayModes.Height = d3dpp.BufferDesc.Height;
|
||||
displayModes.Width = d3dpp.BufferDesc.Width;
|
||||
displayModes.RefreshRate = d3dpp.BufferDesc.RefreshRate;
|
||||
displayModes.Scaling = d3dpp.BufferDesc.Scaling;
|
||||
displayModes.ScanlineOrdering = d3dpp.BufferDesc.ScanlineOrdering;
|
||||
DXGI_MODE_DESC displayModes;
|
||||
displayModes.Format = d3dpp.BufferDesc.Format;
|
||||
displayModes.Height = d3dpp.BufferDesc.Height;
|
||||
displayModes.Width = d3dpp.BufferDesc.Width;
|
||||
displayModes.RefreshRate = d3dpp.BufferDesc.RefreshRate;
|
||||
displayModes.Scaling = d3dpp.BufferDesc.Scaling;
|
||||
displayModes.ScanlineOrdering = d3dpp.BufferDesc.ScanlineOrdering;
|
||||
|
||||
HRESULT hr;
|
||||
if (!d3dpp.Windowed)
|
||||
|
|
@ -523,79 +523,79 @@ void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
|||
}
|
||||
}
|
||||
|
||||
// First release all the stuff we allocated from D3DPOOL_DEFAULT
|
||||
releaseDefaultPoolResources();
|
||||
// First release all the stuff we allocated from D3DPOOL_DEFAULT
|
||||
releaseDefaultPoolResources();
|
||||
|
||||
//release the backbuffer, depthstencil, and their views
|
||||
SAFE_RELEASE(mDeviceBackBufferView);
|
||||
SAFE_RELEASE(mDeviceBackbuffer);
|
||||
SAFE_RELEASE(mDeviceDepthStencilView);
|
||||
SAFE_RELEASE(mDeviceDepthStencil);
|
||||
//release the backbuffer, depthstencil, and their views
|
||||
SAFE_RELEASE(mDeviceBackBufferView);
|
||||
SAFE_RELEASE(mDeviceBackbuffer);
|
||||
SAFE_RELEASE(mDeviceDepthStencilView);
|
||||
SAFE_RELEASE(mDeviceDepthStencil);
|
||||
|
||||
hr = mSwapChain->ResizeBuffers(d3dpp.BufferCount, d3dpp.BufferDesc.Width, d3dpp.BufferDesc.Height, d3dpp.BufferDesc.Format, d3dpp.Windowed ? 0 : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to resize back buffer!");
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to resize back buffer!");
|
||||
}
|
||||
|
||||
//recreate backbuffer view. depth stencil view and texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = d3dpp.BufferDesc.Width;
|
||||
desc.Height = d3dpp.BufferDesc.Height;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.MiscFlags = 0;
|
||||
//recreate backbuffer view. depth stencil view and texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.Width = d3dpp.BufferDesc.Width;
|
||||
desc.Height = d3dpp.BufferDesc.Height;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
hr = mD3DDevice->CreateTexture2D(&desc, NULL, &mDeviceDepthStencil);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create device's depth-stencil surface.");
|
||||
}
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags = 0;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depthDesc;
|
||||
depthDesc.Format = GFXD3D11TextureFormat[GFXFormatD24S8];
|
||||
depthDesc.Flags = 0;
|
||||
depthDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depthDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
hr = mD3DDevice->CreateDepthStencilView(mDeviceDepthStencil, &depthDesc, &mDeviceDepthStencilView);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create depth stencil view");
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create depth stencil view");
|
||||
}
|
||||
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - coudln't retrieve backbuffer ref");
|
||||
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&mDeviceBackbuffer);
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - coudln't retrieve backbuffer ref");
|
||||
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
//create back buffer view
|
||||
D3D11_RENDER_TARGET_VIEW_DESC RTDesc;
|
||||
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
RTDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
RTDesc.Texture2D.MipSlice = 0;
|
||||
RTDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
hr = mD3DDevice->CreateRenderTargetView(mDeviceBackbuffer, &RTDesc, &mDeviceBackBufferView);
|
||||
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create back buffer target view");
|
||||
if (FAILED(hr))
|
||||
AssertFatal(false, "GFXD3D11Device::reset - couldn't create back buffer target view");
|
||||
|
||||
mD3DDeviceContext->OMSetRenderTargets(1, &mDeviceBackBufferView, mDeviceDepthStencilView);
|
||||
|
||||
hr = mSwapChain->SetFullscreenState(!d3dpp.Windowed, NULL);
|
||||
hr = mSwapChain->SetFullscreenState(!d3dpp.Windowed, NULL);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "D3D11Device::reset - failed to change screen states!");
|
||||
}
|
||||
}
|
||||
|
||||
//Microsoft recommend this, see DXGI documentation
|
||||
if (!d3dpp.Windowed)
|
||||
|
|
@ -610,13 +610,13 @@ void GFXD3D11Device::reset(DXGI_SWAP_CHAIN_DESC &d3dpp)
|
|||
}
|
||||
}
|
||||
|
||||
mInitialized = true;
|
||||
mInitialized = true;
|
||||
|
||||
// Now re aquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
// Now re aquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
|
||||
// Mark everything dirty and flush to card, for sanity.
|
||||
updateStates(true);
|
||||
// Mark everything dirty and flush to card, for sanity.
|
||||
updateStates(true);
|
||||
}
|
||||
|
||||
class GFXPCD3D11RegisterDevice
|
||||
|
|
@ -899,20 +899,20 @@ void GFXD3D11Device::_updateRenderTargets()
|
|||
mRTDirty = false;
|
||||
}
|
||||
|
||||
if (mViewportDirty)
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
if (mViewportDirty)
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
|
||||
viewport.TopLeftX = mViewport.point.x;
|
||||
viewport.TopLeftY = mViewport.point.y;
|
||||
viewport.Width = mViewport.extent.x;
|
||||
viewport.Height = mViewport.extent.y;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
viewport.TopLeftX = mViewport.point.x;
|
||||
viewport.TopLeftY = mViewport.point.y;
|
||||
viewport.Width = mViewport.extent.x;
|
||||
viewport.Height = mViewport.extent.y;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
mD3DDeviceContext->RSSetViewports(1, &viewport);
|
||||
mD3DDeviceContext->RSSetViewports(1, &viewport);
|
||||
|
||||
mViewportDirty = false;
|
||||
mViewportDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -970,35 +970,35 @@ void GFXD3D11Device::releaseDefaultPoolResources()
|
|||
|
||||
void GFXD3D11Device::reacquireDefaultPoolResources()
|
||||
{
|
||||
// Now do the dynamic index buffers
|
||||
if( mDynamicPB == NULL )
|
||||
mDynamicPB = new GFXD3D11PrimitiveBuffer(this, 0, 0, GFXBufferTypeDynamic);
|
||||
// Now do the dynamic index buffers
|
||||
if( mDynamicPB == NULL )
|
||||
mDynamicPB = new GFXD3D11PrimitiveBuffer(this, 0, 0, GFXBufferTypeDynamic);
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * MAX_DYNAMIC_INDICES;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * MAX_DYNAMIC_INDICES;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &mDynamicPB->ib);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &mDynamicPB->ib);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic IB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic IB");
|
||||
}
|
||||
|
||||
// Walk the resource list and zombify everything.
|
||||
GFXResource *walk = mResourceListHead;
|
||||
while(walk)
|
||||
{
|
||||
walk->resurrect();
|
||||
walk = walk->getNextResource();
|
||||
}
|
||||
// Walk the resource list and zombify everything.
|
||||
GFXResource *walk = mResourceListHead;
|
||||
while(walk)
|
||||
{
|
||||
walk->resurrect();
|
||||
walk = walk->getNextResource();
|
||||
}
|
||||
|
||||
if(mTextureManager)
|
||||
mTextureManager->resurrect();
|
||||
if(mTextureManager)
|
||||
mTextureManager->resurrect();
|
||||
}
|
||||
|
||||
GFXD3D11VertexBuffer* GFXD3D11Device::findVBPool( const GFXVertexFormat *vertexFormat, U32 vertsNeeded )
|
||||
|
|
@ -1014,40 +1014,40 @@ GFXD3D11VertexBuffer* GFXD3D11Device::findVBPool( const GFXVertexFormat *vertexF
|
|||
|
||||
GFXD3D11VertexBuffer * GFXD3D11Device::createVBPool( const GFXVertexFormat *vertexFormat, U32 vertSize )
|
||||
{
|
||||
PROFILE_SCOPE( GFXD3D11Device_createVBPool );
|
||||
PROFILE_SCOPE( GFXD3D11Device_createVBPool );
|
||||
|
||||
// this is a bit funky, but it will avoid problems with (lack of) copy constructors
|
||||
// with a push_back() situation
|
||||
mVolatileVBList.increment();
|
||||
StrongRefPtr<GFXD3D11VertexBuffer> newBuff;
|
||||
mVolatileVBList.last() = new GFXD3D11VertexBuffer();
|
||||
newBuff = mVolatileVBList.last();
|
||||
// this is a bit funky, but it will avoid problems with (lack of) copy constructors
|
||||
// with a push_back() situation
|
||||
mVolatileVBList.increment();
|
||||
StrongRefPtr<GFXD3D11VertexBuffer> newBuff;
|
||||
mVolatileVBList.last() = new GFXD3D11VertexBuffer();
|
||||
newBuff = mVolatileVBList.last();
|
||||
|
||||
newBuff->mNumVerts = 0;
|
||||
newBuff->mBufferType = GFXBufferTypeVolatile;
|
||||
newBuff->mVertexFormat.copy( *vertexFormat );
|
||||
newBuff->mVertexSize = vertSize;
|
||||
newBuff->mDevice = this;
|
||||
newBuff->mNumVerts = 0;
|
||||
newBuff->mBufferType = GFXBufferTypeVolatile;
|
||||
newBuff->mVertexFormat.copy( *vertexFormat );
|
||||
newBuff->mVertexSize = vertSize;
|
||||
newBuff->mDevice = this;
|
||||
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl();
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl();
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * MAX_DYNAMIC_VERTS;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * MAX_DYNAMIC_VERTS;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &newBuff->vb);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &newBuff->vb);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic VB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate dynamic VB");
|
||||
}
|
||||
|
||||
return newBuff;
|
||||
return newBuff;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1103,30 +1103,30 @@ void GFXD3D11Device::setClipRect( const RectI &inRect )
|
|||
|
||||
void GFXD3D11Device::setVertexStream( U32 stream, GFXVertexBuffer *buffer )
|
||||
{
|
||||
GFXD3D11VertexBuffer *d3dBuffer = static_cast<GFXD3D11VertexBuffer*>( buffer );
|
||||
GFXD3D11VertexBuffer *d3dBuffer = static_cast<GFXD3D11VertexBuffer*>( buffer );
|
||||
|
||||
if ( stream == 0 )
|
||||
{
|
||||
// Set the volatile buffer which is used to
|
||||
// offset the start index when doing draw calls.
|
||||
if ( d3dBuffer && d3dBuffer->mVolatileStart > 0 )
|
||||
mVolatileVB = d3dBuffer;
|
||||
else
|
||||
mVolatileVB = NULL;
|
||||
}
|
||||
if ( stream == 0 )
|
||||
{
|
||||
// Set the volatile buffer which is used to
|
||||
// offset the start index when doing draw calls.
|
||||
if ( d3dBuffer && d3dBuffer->mVolatileStart > 0 )
|
||||
mVolatileVB = d3dBuffer;
|
||||
else
|
||||
mVolatileVB = NULL;
|
||||
}
|
||||
|
||||
// NOTE: We do not use the stream offset here for stream 0
|
||||
// as that feature is *supposedly* not as well supported as
|
||||
// using the start index in drawPrimitive.
|
||||
//
|
||||
// If we can verify that this is not the case then we should
|
||||
// start using this method exclusively for all streams.
|
||||
// NOTE: We do not use the stream offset here for stream 0
|
||||
// as that feature is *supposedly* not as well supported as
|
||||
// using the start index in drawPrimitive.
|
||||
//
|
||||
// If we can verify that this is not the case then we should
|
||||
// start using this method exclusively for all streams.
|
||||
|
||||
U32 strides[1] = { d3dBuffer ? d3dBuffer->mVertexSize : 0 };
|
||||
U32 offset = d3dBuffer && stream != 0 ? d3dBuffer->mVolatileStart * d3dBuffer->mVertexSize : 0;
|
||||
ID3D11Buffer* buff = d3dBuffer ? d3dBuffer->vb : NULL;
|
||||
U32 strides[1] = { d3dBuffer ? d3dBuffer->mVertexSize : 0 };
|
||||
U32 offset = d3dBuffer && stream != 0 ? d3dBuffer->mVolatileStart * d3dBuffer->mVertexSize : 0;
|
||||
ID3D11Buffer* buff = d3dBuffer ? d3dBuffer->vb : NULL;
|
||||
|
||||
getDeviceContext()->IASetVertexBuffers(stream, 1, &buff, strides, &offset);
|
||||
getDeviceContext()->IASetVertexBuffers(stream, 1, &buff, strides, &offset);
|
||||
}
|
||||
|
||||
void GFXD3D11Device::setVertexStreamFrequency( U32 stream, U32 frequency )
|
||||
|
|
@ -1179,7 +1179,7 @@ void GFXD3D11Device::drawPrimitive( GFXPrimitiveType primType, U32 vertexStart,
|
|||
setShaderConstBufferInternal(mCurrentShaderConstBuffer);
|
||||
|
||||
if ( mVolatileVB )
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
vertexStart += mVolatileVB->mVolatileStart;
|
||||
|
||||
mD3DDeviceContext->IASetPrimitiveTopology(GFXD3D11PrimType[primType]);
|
||||
|
||||
|
|
@ -1243,23 +1243,23 @@ void GFXD3D11Device::setShader(GFXShader *shader, bool force)
|
|||
{
|
||||
if(shader)
|
||||
{
|
||||
GFXD3D11Shader *d3dShader = static_cast<GFXD3D11Shader*>(shader);
|
||||
GFXD3D11Shader *d3dShader = static_cast<GFXD3D11Shader*>(shader);
|
||||
|
||||
if (d3dShader->mPixShader != mLastPixShader || force)
|
||||
{
|
||||
mD3DDeviceContext->PSSetShader( d3dShader->mPixShader, NULL, 0);
|
||||
mLastPixShader = d3dShader->mPixShader;
|
||||
}
|
||||
{
|
||||
mD3DDeviceContext->PSSetShader( d3dShader->mPixShader, NULL, 0);
|
||||
mLastPixShader = d3dShader->mPixShader;
|
||||
}
|
||||
|
||||
if (d3dShader->mVertShader != mLastVertShader || force)
|
||||
{
|
||||
mD3DDeviceContext->VSSetShader( d3dShader->mVertShader, NULL, 0);
|
||||
mLastVertShader = d3dShader->mVertShader;
|
||||
}
|
||||
{
|
||||
mD3DDeviceContext->VSSetShader( d3dShader->mVertShader, NULL, 0);
|
||||
mLastVertShader = d3dShader->mVertShader;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setupGenericShaders();
|
||||
setupGenericShaders();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1286,7 +1286,7 @@ GFXPrimitiveBuffer * GFXD3D11Device::allocPrimitiveBuffer(U32 numIndices, U32 nu
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1304,24 +1304,24 @@ GFXPrimitiveBuffer * GFXD3D11Device::allocPrimitiveBuffer(U32 numIndices, U32 nu
|
|||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, get it as a seperate buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * numIndices;
|
||||
desc.Usage = usage;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a primitive buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
// Otherwise, get it as a seperate buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(U16) * numIndices;
|
||||
desc.Usage = usage;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a primitive buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->ib);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->ib);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate an index buffer.");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate an index buffer.");
|
||||
}
|
||||
}
|
||||
|
||||
if (data)
|
||||
|
|
@ -1365,7 +1365,7 @@ GFXVertexBuffer * GFXD3D11Device::allocVertexBuffer(U32 numVerts, const GFXVerte
|
|||
|
||||
case GFXBufferTypeDynamic:
|
||||
case GFXBufferTypeVolatile:
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
usage = D3D11_USAGE_DYNAMIC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1380,27 +1380,27 @@ GFXVertexBuffer * GFXD3D11Device::allocVertexBuffer(U32 numVerts, const GFXVerte
|
|||
}
|
||||
else
|
||||
{
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl(); //-ALEX disabled to postpone until after shader is actually set...
|
||||
// Requesting it will allocate it.
|
||||
vertexFormat->getDecl(); //-ALEX disabled to postpone until after shader is actually set...
|
||||
|
||||
// Get a new buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * numVerts;
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a vertex buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
// Get a new buffer...
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = vertSize * numVerts;
|
||||
desc.Usage = usage;
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
if(bufferType == GFXBufferTypeDynamic)
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // We never allow reading from a vertex buffer.
|
||||
else
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->vb);
|
||||
HRESULT hr = D3D11DEVICE->CreateBuffer(&desc, NULL, &res->vb);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate VB");
|
||||
}
|
||||
if(FAILED(hr))
|
||||
{
|
||||
AssertFatal(false, "Failed to allocate VB");
|
||||
}
|
||||
}
|
||||
|
||||
res->mNumVerts = numVerts;
|
||||
|
|
@ -1597,7 +1597,6 @@ GFXVertexDecl* GFXD3D11Device::allocVertexDecl( const GFXVertexFormat *vertexFor
|
|||
|
||||
S32 elemIndex = 0;
|
||||
for (S32 i = 0; i < elemCount; i++, elemIndex++)
|
||||
{
|
||||
|
||||
const GFXVertexElement &element = vertexFormat->getElement(elemIndex);
|
||||
|
||||
|
|
@ -1690,9 +1689,9 @@ void GFXD3D11Device::setTextureInternal( U32 textureUnit, const GFXTextureObject
|
|||
{
|
||||
if( texture == NULL )
|
||||
{
|
||||
ID3D11ShaderResourceView *pView = NULL;
|
||||
mD3DDeviceContext->PSSetShaderResources(textureUnit, 1, &pView);
|
||||
return;
|
||||
ID3D11ShaderResourceView *pView = NULL;
|
||||
mD3DDeviceContext->PSSetShaderResources(textureUnit, 1, &pView);
|
||||
return;
|
||||
}
|
||||
|
||||
GFXD3D11TextureObject *tex = (GFXD3D11TextureObject*)(texture);
|
||||
|
|
@ -1704,23 +1703,23 @@ GFXFence *GFXD3D11Device::createFence()
|
|||
// Figure out what fence type we should be making if we don't know
|
||||
if( mCreateFenceType == -1 )
|
||||
{
|
||||
D3D11_QUERY_DESC desc;
|
||||
desc.MiscFlags = 0;
|
||||
desc.Query = D3D11_QUERY_EVENT;
|
||||
D3D11_QUERY_DESC desc;
|
||||
desc.MiscFlags = 0;
|
||||
desc.Query = D3D11_QUERY_EVENT;
|
||||
|
||||
ID3D11Query *testQuery = NULL;
|
||||
ID3D11Query *testQuery = NULL;
|
||||
|
||||
HRESULT hRes = mD3DDevice->CreateQuery(&desc, &testQuery);
|
||||
HRESULT hRes = mD3DDevice->CreateQuery(&desc, &testQuery);
|
||||
|
||||
if(FAILED(hRes))
|
||||
{
|
||||
mCreateFenceType = true;
|
||||
}
|
||||
if(FAILED(hRes))
|
||||
{
|
||||
mCreateFenceType = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
mCreateFenceType = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCreateFenceType = false;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(testQuery);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
if( tex == GFXTextureTarget::sDefaultDepthStencil )
|
||||
{
|
||||
mTargets[slot] = D3D11->mDeviceDepthStencil;
|
||||
mTargetViews[slot] = D3D11->mDeviceDepthStencilView;
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargetViews[slot] = D3D11->mDeviceDepthStencilView;
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot]->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -110,14 +110,14 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
|
||||
// Grab the surface level.
|
||||
if( slot == DepthStencil )
|
||||
{
|
||||
{
|
||||
mTargets[slot] = d3dto->getSurface();
|
||||
if ( mTargets[slot] )
|
||||
mTargets[slot]->AddRef();
|
||||
|
||||
mTargetViews[slot] = d3dto->getDSView();
|
||||
if( mTargetViews[slot])
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getDSView();
|
||||
if( mTargetViews[slot])
|
||||
mTargetViews[slot]->AddRef();
|
||||
|
||||
}
|
||||
else
|
||||
|
|
@ -126,12 +126,12 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
// if the surface that it needs to render to is different than the mip level
|
||||
// in the actual texture. This will happen with MSAA.
|
||||
if( d3dto->getSurface() == NULL )
|
||||
{
|
||||
{
|
||||
|
||||
mTargets[slot] = d3dto->get2DTex();
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getRTView();
|
||||
mTargetViews[slot]->AddRef();
|
||||
mTargets[slot] = d3dto->get2DTex();
|
||||
mTargets[slot]->AddRef();
|
||||
mTargetViews[slot] = d3dto->getRTView();
|
||||
mTargetViews[slot]->AddRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -164,11 +164,11 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
|||
|
||||
S32 format = sd.Format;
|
||||
|
||||
if (format == DXGI_FORMAT_R8G8B8A8_TYPELESS || format == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
mTargetFormat = GFXFormatR8G8B8A8;
|
||||
return;
|
||||
}
|
||||
if (format == DXGI_FORMAT_R8G8B8A8_TYPELESS || format == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
mTargetFormat = GFXFormatR8G8B8A8;
|
||||
return;
|
||||
}
|
||||
|
||||
GFXREVERSE_LOOKUP( GFXD3D11TextureFormat, GFXFormat, format );
|
||||
mTargetFormat = (GFXFormat)format;
|
||||
|
|
@ -283,7 +283,7 @@ void GFXD3D11TextureTarget::resolve()
|
|||
if (mResolveTargets[i])
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
mTargets[i]->GetDesc(&desc);
|
||||
mTargets[i]->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->CopySubresourceRegion(mResolveTargets[i]->get2DTex(), 0, 0, 0, 0, mTargets[i], 0, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -407,10 +407,10 @@ void GFXD3D11WindowTarget::activate()
|
|||
|
||||
void GFXD3D11WindowTarget::resolveTo(GFXTextureObject *tex)
|
||||
{
|
||||
GFXDEBUGEVENT_SCOPE(GFXPCD3D11WindowTarget_resolveTo, ColorI::RED);
|
||||
GFXDEBUGEVENT_SCOPE(GFXPCD3D11WindowTarget_resolveTo, ColorI::RED);
|
||||
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ID3D11Texture2D* surf = ((GFXD3D11TextureObject*)(tex))->get2DTex();
|
||||
surf->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->ResolveSubresource(surf, 0, D3D11->mDeviceBackbuffer, 0, desc.Format);
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ID3D11Texture2D* surf = ((GFXD3D11TextureObject*)(tex))->get2DTex();
|
||||
surf->GetDesc(&desc);
|
||||
D3D11DEVICECONTEXT->ResolveSubresource(surf, 0, D3D11->mDeviceBackbuffer, 0, desc.Format);
|
||||
}
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
struct GFXAdapterLUID
|
||||
{
|
||||
unsigned long LowPart;
|
||||
long HighPart;
|
||||
unsigned long LowPart;
|
||||
long HighPart;
|
||||
};
|
||||
|
||||
struct GFXAdapter
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ GFXDevice::GFXDevice()
|
|||
// misc
|
||||
mAllowRender = true;
|
||||
mCurrentRenderStyle = RS_Standard;
|
||||
mCurrentStereoTarget = -1;
|
||||
mStereoHeadTransform = MatrixF(1);
|
||||
mCurrentStereoTarget = -1;
|
||||
mStereoHeadTransform = MatrixF(1);
|
||||
mCanCurrentlyRender = false;
|
||||
mInitialized = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -219,11 +219,11 @@ public:
|
|||
/// The device has started rendering a frame's field (such as for side-by-side rendering)
|
||||
deStartOfField,
|
||||
|
||||
/// left stereo frame has been rendered
|
||||
deLeftStereoFrameRendered,
|
||||
/// left stereo frame has been rendered
|
||||
deLeftStereoFrameRendered,
|
||||
|
||||
/// right stereo frame has been rendered
|
||||
deRightStereoFrameRendered,
|
||||
/// right stereo frame has been rendered
|
||||
deRightStereoFrameRendered,
|
||||
|
||||
/// The device is about to finish rendering a frame's field
|
||||
deEndOfField,
|
||||
|
|
@ -254,7 +254,7 @@ public:
|
|||
{
|
||||
RS_Standard = 0,
|
||||
RS_StereoSideBySide = (1<<0), // Render into current Render Target side-by-side
|
||||
RS_StereoSeparate = (1<<1) // Render in two separate passes (then combined by vr compositor)
|
||||
RS_StereoSeparate = (1<<1) // Render in two separate passes (then combined by vr compositor)
|
||||
};
|
||||
|
||||
enum GFXDeviceLimits
|
||||
|
|
@ -409,7 +409,7 @@ public:
|
|||
setViewport(mStereoViewports[eyeId]);
|
||||
}
|
||||
|
||||
mCurrentStereoTarget = eyeId;
|
||||
mCurrentStereoTarget = eyeId;
|
||||
}
|
||||
|
||||
GFXCardProfiler* getCardProfiler() const { return mCardProfiler; }
|
||||
|
|
@ -481,7 +481,7 @@ public:
|
|||
/// Returns the first format from the list which meets all
|
||||
/// the criteria of the texture profile and query options.
|
||||
virtual GFXFormat selectSupportedFormat(GFXTextureProfile *profile,
|
||||
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter) = 0;
|
||||
const Vector<GFXFormat> &formats, bool texture, bool mustblend, bool mustfilter) = 0;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ void GFXDrawUtil::_setupStateBlocks()
|
|||
bitmapStretchSR.setZReadWrite(false);
|
||||
bitmapStretchSR.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
|
||||
bitmapStretchSR.samplersDefined = true;
|
||||
bitmapStretchSR.setColorWrites(true, true, true, false);
|
||||
bitmapStretchSR.setColorWrites(true, true, true, false); // NOTE: comment this out if alpha write is needed
|
||||
|
||||
// Linear: Create wrap SB
|
||||
bitmapStretchSR.samplers[0] = GFXSamplerStateDesc::getWrapLinear();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ FontRenderBatcher::FontRenderBatcher() : mStorage(8096)
|
|||
// so it may have to change. -bramage
|
||||
f.samplers[0].textureColorOp = GFXTOPAdd;
|
||||
|
||||
f.setColorWrites(true, true, true, false);
|
||||
f.setColorWrites(true, true, true, false); // NOTE: comment this out if alpha write is needed
|
||||
mFontSB = GFX->createStateBlock(f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,18 +200,18 @@ GFXAdapter* GFXInit::getAdapterOfType( GFXAdapterType type, const char* outputDe
|
|||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (U32 i = 0; i < smAdapters.size(); i++)
|
||||
{
|
||||
if (smAdapters[i]->mType == type)
|
||||
{
|
||||
if (smAdapters[i]->mIndex == outputDeviceIndex)
|
||||
{
|
||||
return smAdapters[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevice)
|
||||
|
|
@ -237,23 +237,23 @@ GFXAdapter* GFXInit::chooseAdapter( GFXAdapterType type, const char* outputDevic
|
|||
|
||||
GFXAdapter* GFXInit::chooseAdapter(GFXAdapterType type, S32 outputDeviceIndex)
|
||||
{
|
||||
GFXAdapter* adapter = GFXInit::getAdapterOfType(type, 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 && 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);
|
||||
}
|
||||
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;
|
||||
AssertFatal(adapter, "There is no rendering device available whatsoever.");
|
||||
return adapter;
|
||||
}
|
||||
|
||||
const char* GFXInit::getAdapterNameFromType(GFXAdapterType type)
|
||||
|
|
@ -304,11 +304,11 @@ GFXAdapter *GFXInit::getBestAdapterChoice()
|
|||
}
|
||||
else
|
||||
{
|
||||
S32 adapterIdx = dAtoi(adapterDevice.c_str());
|
||||
if (adapterIdx == -1)
|
||||
adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
else
|
||||
adapter = chooseAdapter(adapterType, adapterIdx);
|
||||
S32 adapterIdx = dAtoi(adapterDevice.c_str());
|
||||
if (adapterIdx == -1)
|
||||
adapter = chooseAdapter(adapterType, outputDevice.c_str());
|
||||
else
|
||||
adapter = chooseAdapter(adapterType, adapterIdx);
|
||||
}
|
||||
|
||||
// Did they have one? Return it.
|
||||
|
|
|
|||
|
|
@ -74,16 +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 );
|
||||
/// 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 );
|
||||
/// 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 );
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ public:
|
|||
/// This is mainly a depth buffer optimization.
|
||||
NoDiscard = BIT(10),
|
||||
|
||||
/// Texture is managed by another process, thus should not be modified
|
||||
NoModify = BIT(11)
|
||||
/// Texture is managed by another process, thus should not be modified
|
||||
NoModify = BIT(11)
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -167,7 +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); }
|
||||
inline bool canModify() const { return !testFlag(NoModify); }
|
||||
|
||||
private:
|
||||
/// These constants control the packing for the profile; if you add flags, types, or
|
||||
|
|
|
|||
|
|
@ -141,73 +141,73 @@ void DebugDrawer::setupStateBlocks()
|
|||
|
||||
void DebugDrawer::drawBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
}
|
||||
|
||||
void DebugDrawer::drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color, const MatrixF& transform)
|
||||
{
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
Point3F point0(a.x, a.y, a.z);
|
||||
Point3F point1(a.x, b.y, a.z);
|
||||
Point3F point2(b.x, b.y, a.z);
|
||||
Point3F point3(b.x, a.y, a.z);
|
||||
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
Point3F point4(a.x, a.y, b.z);
|
||||
Point3F point5(a.x, b.y, b.z);
|
||||
Point3F point6(b.x, b.y, b.z);
|
||||
Point3F point7(b.x, a.y, b.z);
|
||||
|
||||
transform.mulP(point0);
|
||||
transform.mulP(point1);
|
||||
transform.mulP(point2);
|
||||
transform.mulP(point3);
|
||||
transform.mulP(point4);
|
||||
transform.mulP(point5);
|
||||
transform.mulP(point6);
|
||||
transform.mulP(point7);
|
||||
transform.mulP(point0);
|
||||
transform.mulP(point1);
|
||||
transform.mulP(point2);
|
||||
transform.mulP(point3);
|
||||
transform.mulP(point4);
|
||||
transform.mulP(point5);
|
||||
transform.mulP(point6);
|
||||
transform.mulP(point7);
|
||||
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
// Draw one plane
|
||||
drawLine(point0, point1, color);
|
||||
drawLine(point1, point2, color);
|
||||
drawLine(point2, point3, color);
|
||||
drawLine(point3, point0, color);
|
||||
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
// Draw the other plane
|
||||
drawLine(point4, point5, color);
|
||||
drawLine(point5, point6, color);
|
||||
drawLine(point6, point7, color);
|
||||
drawLine(point7, point4, color);
|
||||
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
// Draw the connecting corners
|
||||
drawLine(point0, point4, color);
|
||||
drawLine(point1, point5, color);
|
||||
drawLine(point2, point6, color);
|
||||
drawLine(point3, point7, color);
|
||||
}
|
||||
|
||||
void DebugDrawer::render(bool clear)
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public:
|
|||
void drawTransformedBoxOutline(const Point3F &a, const Point3F &b, const ColorF &color, const MatrixF& transform);
|
||||
|
||||
void drawBox(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawText(const Point3F& pos, const String& text, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f));
|
||||
|
|
@ -181,7 +181,7 @@ private:
|
|||
DirectionLine,
|
||||
OutlinedText,
|
||||
Capsule,
|
||||
} type; ///< Type of the primitive. The meanings of a,b,c are determined by this.
|
||||
} type; ///< Type of the primitive. The meanings of a,b,c are determined by this.
|
||||
|
||||
SimTime dieTime; ///< Time at which we should remove this from the list.
|
||||
bool useZ; ///< If true, do z-checks for this primitive.
|
||||
|
|
|
|||
|
|
@ -64,9 +64,9 @@ Vector<GuiTSCtrl*> GuiTSCtrl::smAwakeTSCtrls;
|
|||
ImplementEnumType( GuiTSRenderStyles,
|
||||
"Style of rendering for a GuiTSCtrl.\n\n"
|
||||
"@ingroup Gui3D" )
|
||||
{ GuiTSCtrl::RenderStyleStandard, "standard" },
|
||||
{ GuiTSCtrl::RenderStyleStereoSideBySide, "stereo side by side" },
|
||||
{ GuiTSCtrl::RenderStyleStereoSeparate, "stereo separate" },
|
||||
{ GuiTSCtrl::RenderStyleStandard, "standard" },
|
||||
{ GuiTSCtrl::RenderStyleStereoSideBySide, "stereo side by side" },
|
||||
{ GuiTSCtrl::RenderStyleStereoSeparate, "stereo separate" },
|
||||
EndImplementEnumType;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -199,9 +199,9 @@ void GuiTSCtrl::initPersistFields()
|
|||
void GuiTSCtrl::consoleInit()
|
||||
{
|
||||
Con::addVariable("$TSControl::frameCount", TypeS32, &smFrameCount, "The number of frames that have been rendered since this control was created.\n"
|
||||
"@ingroup Rendering\n");
|
||||
"@ingroup Rendering\n");
|
||||
Con::addVariable("$TSControl::useLatestDisplayTransform", TypeBool, &smUseLatestDisplayTransform, "Use the latest view transform when rendering stereo instead of the one calculated by the last move.\n"
|
||||
"@ingroup Rendering\n");
|
||||
"@ingroup Rendering\n");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -371,15 +371,15 @@ void GuiTSCtrl::_internalRender(RectI guiViewport, RectI renderViewport, Frustum
|
|||
|
||||
if (mReflectPriority > 0)
|
||||
{
|
||||
// Get the total reflection priority.
|
||||
F32 totalPriority = 0;
|
||||
for (U32 i = 0; i < smAwakeTSCtrls.size(); i++)
|
||||
if (smAwakeTSCtrls[i]->isVisible())
|
||||
totalPriority += smAwakeTSCtrls[i]->mReflectPriority;
|
||||
// Get the total reflection priority.
|
||||
F32 totalPriority = 0;
|
||||
for (U32 i = 0; i < smAwakeTSCtrls.size(); i++)
|
||||
if (smAwakeTSCtrls[i]->isVisible())
|
||||
totalPriority += smAwakeTSCtrls[i]->mReflectPriority;
|
||||
|
||||
REFLECTMGR->update(mReflectPriority / totalPriority,
|
||||
renderSize,
|
||||
mLastCameraQuery);
|
||||
REFLECTMGR->update(mReflectPriority / totalPriority,
|
||||
renderSize,
|
||||
mLastCameraQuery);
|
||||
}
|
||||
|
||||
GFX->setActiveRenderTarget(origTarget);
|
||||
|
|
@ -431,22 +431,22 @@ void GuiTSCtrl::_internalRender(RectI guiViewport, RectI renderViewport, Frustum
|
|||
DebugDrawer* debugDraw = DebugDrawer::get();
|
||||
if (mRenderStyle == RenderStyleStereoSideBySide && debugDraw->willDraw())
|
||||
{
|
||||
// For SBS we need to render over each viewport
|
||||
Frustum frustum;
|
||||
// For SBS we need to render over each viewport
|
||||
Frustum frustum;
|
||||
|
||||
GFX->setViewport(mLastCameraQuery.stereoViewports[0]);
|
||||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[0]);
|
||||
GFX->setFrustum(frustum);
|
||||
debugDraw->render(false);
|
||||
GFX->setViewport(mLastCameraQuery.stereoViewports[0]);
|
||||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[0]);
|
||||
GFX->setFrustum(frustum);
|
||||
debugDraw->render(false);
|
||||
|
||||
GFX->setViewport(mLastCameraQuery.stereoViewports[1]);
|
||||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[1]);
|
||||
GFX->setFrustum(frustum);
|
||||
debugDraw->render();
|
||||
GFX->setViewport(mLastCameraQuery.stereoViewports[1]);
|
||||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[1]);
|
||||
GFX->setFrustum(frustum);
|
||||
debugDraw->render();
|
||||
}
|
||||
else
|
||||
{
|
||||
debugDraw->render();
|
||||
debugDraw->render();
|
||||
}
|
||||
|
||||
saver.restore();
|
||||
|
|
@ -637,23 +637,23 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[0]);
|
||||
mLastCameraQuery.cameraMatrix = myTransforms[0];
|
||||
frustum.update();
|
||||
GFX->activateStereoTarget(0);
|
||||
mLastCameraQuery.currentEye = 0;
|
||||
GFX->beginField();
|
||||
_internalRender(RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), frustum);
|
||||
GFX->activateStereoTarget(0);
|
||||
mLastCameraQuery.currentEye = 0;
|
||||
GFX->beginField();
|
||||
_internalRender(RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), frustum);
|
||||
GFX->getDeviceEventSignal().trigger(GFXDevice::deLeftStereoFrameRendered);
|
||||
GFX->endField();
|
||||
GFX->endField();
|
||||
|
||||
// Right
|
||||
GFX->activateStereoTarget(1);
|
||||
mLastCameraQuery.currentEye = 1;
|
||||
GFX->activateStereoTarget(1);
|
||||
mLastCameraQuery.currentEye = 1;
|
||||
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[1]);
|
||||
mLastCameraQuery.cameraMatrix = myTransforms[1];
|
||||
frustum.update();
|
||||
GFX->beginField();
|
||||
_internalRender(RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[1]->getSize()), RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), frustum);
|
||||
GFX->getDeviceEventSignal().trigger(GFXDevice::deRightStereoFrameRendered);
|
||||
GFX->endField();
|
||||
frustum.update();
|
||||
GFX->beginField();
|
||||
_internalRender(RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[1]->getSize()), RectI(Point2I(0, 0), mLastCameraQuery.stereoTargets[0]->getSize()), frustum);
|
||||
GFX->getDeviceEventSignal().trigger(GFXDevice::deRightStereoFrameRendered);
|
||||
GFX->endField();
|
||||
|
||||
mLastCameraQuery.cameraMatrix = origMatrix;
|
||||
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ protected:
|
|||
/// Which HMD is the active one
|
||||
U32 mActiveDeviceId;
|
||||
|
||||
/// Device id we need to use to hook up with oculus
|
||||
ovrGraphicsLuid mLuid;
|
||||
/// Device id we need to use to hook up with oculus
|
||||
ovrGraphicsLuid mLuid;
|
||||
|
||||
protected:
|
||||
void cleanUp();
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@
|
|||
|
||||
struct OculusTexture
|
||||
{
|
||||
virtual void AdvanceToNextTexture() = 0;
|
||||
virtual void AdvanceToNextTexture() = 0;
|
||||
|
||||
virtual ~OculusTexture() {
|
||||
}
|
||||
virtual ~OculusTexture() {
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
@ -57,105 +57,105 @@ struct OculusTexture
|
|||
// needed for D3D11 rendering.
|
||||
struct D3D11OculusTexture : public OculusTexture
|
||||
{
|
||||
ovrHmd hmd;
|
||||
ovrSwapTextureSet * TextureSet;
|
||||
static const int TextureCount = 2;
|
||||
GFXTexHandle TexRtv[TextureCount];
|
||||
GFXDevice *Owner;
|
||||
ovrHmd hmd;
|
||||
ovrSwapTextureSet * TextureSet;
|
||||
static const int TextureCount = 2;
|
||||
GFXTexHandle TexRtv[TextureCount];
|
||||
GFXDevice *Owner;
|
||||
|
||||
D3D11OculusTexture(GFXDevice* owner) :
|
||||
hmd(nullptr),
|
||||
TextureSet(nullptr),
|
||||
Owner(owner)
|
||||
{
|
||||
TexRtv[0] = TexRtv[1] = nullptr;
|
||||
}
|
||||
D3D11OculusTexture(GFXDevice* owner) :
|
||||
hmd(nullptr),
|
||||
TextureSet(nullptr),
|
||||
Owner(owner)
|
||||
{
|
||||
TexRtv[0] = TexRtv[1] = nullptr;
|
||||
}
|
||||
|
||||
bool Init(ovrHmd _hmd, int sizeW, int sizeH)
|
||||
{
|
||||
hmd = _hmd;
|
||||
bool Init(ovrHmd _hmd, int sizeW, int sizeH)
|
||||
{
|
||||
hmd = _hmd;
|
||||
|
||||
D3D11_TEXTURE2D_DESC dsDesc;
|
||||
dsDesc.Width = sizeW;
|
||||
dsDesc.Height = sizeH;
|
||||
dsDesc.MipLevels = 1;
|
||||
dsDesc.ArraySize = 1;
|
||||
dsDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;// DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
dsDesc.SampleDesc.Count = 1; // No multi-sampling allowed
|
||||
dsDesc.SampleDesc.Quality = 0;
|
||||
dsDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
dsDesc.CPUAccessFlags = 0;
|
||||
dsDesc.MiscFlags = 0;
|
||||
dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
|
||||
D3D11_TEXTURE2D_DESC dsDesc;
|
||||
dsDesc.Width = sizeW;
|
||||
dsDesc.Height = sizeH;
|
||||
dsDesc.MipLevels = 1;
|
||||
dsDesc.ArraySize = 1;
|
||||
dsDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;// DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
dsDesc.SampleDesc.Count = 1; // No multi-sampling allowed
|
||||
dsDesc.SampleDesc.Quality = 0;
|
||||
dsDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
dsDesc.CPUAccessFlags = 0;
|
||||
dsDesc.MiscFlags = 0;
|
||||
dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
|
||||
|
||||
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
ovrResult result = ovr_CreateSwapTextureSetD3D11(hmd, device->mD3DDevice, &dsDesc, ovrSwapTextureSetD3D11_Typeless, &TextureSet);
|
||||
if (!OVR_SUCCESS(result))
|
||||
return false;
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
ovrResult result = ovr_CreateSwapTextureSetD3D11(hmd, device->mD3DDevice, &dsDesc, ovrSwapTextureSetD3D11_Typeless, &TextureSet);
|
||||
if (!OVR_SUCCESS(result))
|
||||
return false;
|
||||
|
||||
AssertFatal(TextureSet->TextureCount == TextureCount, "TextureCount mismatch.");
|
||||
AssertFatal(TextureSet->TextureCount == TextureCount, "TextureCount mismatch.");
|
||||
|
||||
for (int i = 0; i < TextureCount; ++i)
|
||||
{
|
||||
ovrD3D11Texture* tex = (ovrD3D11Texture*)&TextureSet->Textures[i];
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
|
||||
rtvd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;// DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
for (int i = 0; i < TextureCount; ++i)
|
||||
{
|
||||
ovrD3D11Texture* tex = (ovrD3D11Texture*)&TextureSet->Textures[i];
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
|
||||
rtvd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;// DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
GFXD3D11TextureObject* object = new GFXD3D11TextureObject(GFX, &VRTextureProfile);
|
||||
object->registerResourceWithDevice(GFX);
|
||||
*(object->getSRViewPtr()) = tex->D3D11.pSRView;
|
||||
*(object->get2DTexPtr()) = tex->D3D11.pTexture;
|
||||
device->mD3DDevice->CreateRenderTargetView(tex->D3D11.pTexture, &rtvd, object->getRTViewPtr());
|
||||
GFXD3D11TextureObject* object = new GFXD3D11TextureObject(GFX, &VRTextureProfile);
|
||||
object->registerResourceWithDevice(GFX);
|
||||
*(object->getSRViewPtr()) = tex->D3D11.pSRView;
|
||||
*(object->get2DTexPtr()) = tex->D3D11.pTexture;
|
||||
device->mD3DDevice->CreateRenderTargetView(tex->D3D11.pTexture, &rtvd, object->getRTViewPtr());
|
||||
|
||||
// Add refs for texture release later on
|
||||
if (object->getSRView()) object->getSRView()->AddRef();
|
||||
//object->getRTView()->AddRef();
|
||||
if (object->get2DTex()) object->get2DTex()->AddRef();
|
||||
object->isManaged = true;
|
||||
// Add refs for texture release later on
|
||||
if (object->getSRView()) object->getSRView()->AddRef();
|
||||
//object->getRTView()->AddRef();
|
||||
if (object->get2DTex()) object->get2DTex()->AddRef();
|
||||
object->isManaged = true;
|
||||
|
||||
// Get the actual size of the texture...
|
||||
D3D11_TEXTURE2D_DESC probeDesc;
|
||||
ZeroMemory(&probeDesc, sizeof(D3D11_TEXTURE2D_DESC));
|
||||
object->get2DTex()->GetDesc(&probeDesc);
|
||||
// Get the actual size of the texture...
|
||||
D3D11_TEXTURE2D_DESC probeDesc;
|
||||
ZeroMemory(&probeDesc, sizeof(D3D11_TEXTURE2D_DESC));
|
||||
object->get2DTex()->GetDesc(&probeDesc);
|
||||
|
||||
object->mTextureSize.set(probeDesc.Width, probeDesc.Height, 0);
|
||||
object->mBitmapSize = object->mTextureSize;
|
||||
int fmt = probeDesc.Format;
|
||||
object->mTextureSize.set(probeDesc.Width, probeDesc.Height, 0);
|
||||
object->mBitmapSize = object->mTextureSize;
|
||||
int fmt = probeDesc.Format;
|
||||
|
||||
if (fmt == DXGI_FORMAT_R8G8B8A8_TYPELESS || fmt == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
object->mFormat = GFXFormatR8G8B8A8; // usual case
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: improve this. this can be very bad.
|
||||
GFXREVERSE_LOOKUP(GFXD3D11TextureFormat, GFXFormat, fmt);
|
||||
object->mFormat = (GFXFormat)fmt;
|
||||
}
|
||||
TexRtv[i] = object;
|
||||
}
|
||||
if (fmt == DXGI_FORMAT_R8G8B8A8_TYPELESS || fmt == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
object->mFormat = GFXFormatR8G8B8A8; // usual case
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: improve this. this can be very bad.
|
||||
GFXREVERSE_LOOKUP(GFXD3D11TextureFormat, GFXFormat, fmt);
|
||||
object->mFormat = (GFXFormat)fmt;
|
||||
}
|
||||
TexRtv[i] = object;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
~D3D11OculusTexture()
|
||||
{
|
||||
for (int i = 0; i < TextureCount; ++i)
|
||||
{
|
||||
SAFE_DELETE(TexRtv[i]);
|
||||
}
|
||||
if (TextureSet)
|
||||
{
|
||||
ovr_DestroySwapTextureSet(hmd, TextureSet);
|
||||
}
|
||||
}
|
||||
~D3D11OculusTexture()
|
||||
{
|
||||
for (int i = 0; i < TextureCount; ++i)
|
||||
{
|
||||
SAFE_DELETE(TexRtv[i]);
|
||||
}
|
||||
if (TextureSet)
|
||||
{
|
||||
ovr_DestroySwapTextureSet(hmd, TextureSet);
|
||||
}
|
||||
}
|
||||
|
||||
void AdvanceToNextTexture()
|
||||
{
|
||||
TextureSet->CurrentIndex = (TextureSet->CurrentIndex + 1) % TextureSet->TextureCount;
|
||||
}
|
||||
void AdvanceToNextTexture()
|
||||
{
|
||||
TextureSet->CurrentIndex = (TextureSet->CurrentIndex + 1) % TextureSet->TextureCount;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ OculusVRHMDDevice::OculusVRHMDDevice()
|
|||
mConnection = NULL;
|
||||
mSensor = NULL;
|
||||
mActionCodeIndex = 0;
|
||||
mTextureSwapSet = NULL;
|
||||
mTextureSwapSet = NULL;
|
||||
}
|
||||
|
||||
OculusVRHMDDevice::~OculusVRHMDDevice()
|
||||
|
|
@ -212,35 +212,35 @@ void OculusVRHMDDevice::set(ovrHmd hmd, ovrGraphicsLuid luid, U32 actionCodeInde
|
|||
|
||||
mDevice = hmd;
|
||||
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(hmd);
|
||||
int caps = ovr_GetTrackingCaps(hmd);
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(hmd);
|
||||
int caps = ovr_GetTrackingCaps(hmd);
|
||||
|
||||
mSupportedCaps = desc.AvailableHmdCaps;
|
||||
mCurrentCaps = mSupportedCaps;
|
||||
|
||||
mTimewarp = true;
|
||||
mCurrentCaps = mSupportedCaps;
|
||||
|
||||
mTimewarp = true;
|
||||
|
||||
// DeviceInfo
|
||||
mProductName = desc.ProductName;
|
||||
mManufacturer = desc.Manufacturer;
|
||||
mVersion = desc.FirmwareMajor;
|
||||
|
||||
//
|
||||
Vector<GFXAdapter*> adapterList;
|
||||
GFXD3D11Device::enumerateAdapters(adapterList);
|
||||
//
|
||||
Vector<GFXAdapter*> adapterList;
|
||||
GFXD3D11Device::enumerateAdapters(adapterList);
|
||||
|
||||
dMemcpy(&mLuid, &luid, sizeof(mLuid));
|
||||
mDisplayId = -1;
|
||||
dMemcpy(&mLuid, &luid, sizeof(mLuid));
|
||||
mDisplayId = -1;
|
||||
|
||||
for (U32 i = 0, sz = adapterList.size(); i < sz; i++)
|
||||
{
|
||||
GFXAdapter* adapter = adapterList[i];
|
||||
if (dMemcmp(&adapter->mLUID, &mLuid, sizeof(mLuid)) == 0)
|
||||
{
|
||||
mDisplayId = adapter->mIndex;
|
||||
mDisplayDeviceType = "D3D11"; // TOFIX this
|
||||
}
|
||||
}
|
||||
for (U32 i = 0, sz = adapterList.size(); i < sz; i++)
|
||||
{
|
||||
GFXAdapter* adapter = adapterList[i];
|
||||
if (dMemcmp(&adapter->mLUID, &mLuid, sizeof(mLuid)) == 0)
|
||||
{
|
||||
mDisplayId = adapter->mIndex;
|
||||
mDisplayDeviceType = "D3D11"; // TOFIX this
|
||||
}
|
||||
}
|
||||
|
||||
mResolution.x = desc.Resolution.w;
|
||||
mResolution.y = desc.Resolution.h;
|
||||
|
|
@ -256,7 +256,7 @@ void OculusVRHMDDevice::set(ovrHmd hmd, ovrGraphicsLuid luid, U32 actionCodeInde
|
|||
mSensor = new OculusVRSensorDevice();
|
||||
mSensor->set(mDevice, mActionCodeIndex);
|
||||
|
||||
mDebugMirrorTexture = NULL;
|
||||
mDebugMirrorTexture = NULL;
|
||||
|
||||
updateCaps();
|
||||
}
|
||||
|
|
@ -274,15 +274,15 @@ void OculusVRHMDDevice::setOptimalDisplaySize(GuiCanvas *canvas)
|
|||
PlatformWindow *window = canvas->getPlatformWindow();
|
||||
GFXTarget *target = window->getGFXTarget();
|
||||
|
||||
Point2I requiredSize(0, 0);
|
||||
Point2I requiredSize(0, 0);
|
||||
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
ovrSizei leftSize = ovr_GetFovTextureSize(mDevice, ovrEye_Left, desc.DefaultEyeFov[0], mCurrentPixelDensity);
|
||||
ovrSizei rightSize = ovr_GetFovTextureSize(mDevice, ovrEye_Right, desc.DefaultEyeFov[1], mCurrentPixelDensity);
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
ovrSizei leftSize = ovr_GetFovTextureSize(mDevice, ovrEye_Left, desc.DefaultEyeFov[0], mCurrentPixelDensity);
|
||||
ovrSizei rightSize = ovr_GetFovTextureSize(mDevice, ovrEye_Right, desc.DefaultEyeFov[1], mCurrentPixelDensity);
|
||||
|
||||
requiredSize.x = leftSize.w + rightSize.h;
|
||||
requiredSize.y = mMax(leftSize.h, rightSize.h);
|
||||
|
||||
requiredSize.x = leftSize.w + rightSize.h;
|
||||
requiredSize.y = mMax(leftSize.h, rightSize.h);
|
||||
|
||||
if (target && target->getSize() != requiredSize)
|
||||
{
|
||||
GFXVideoMode newMode;
|
||||
|
|
@ -302,7 +302,7 @@ bool OculusVRHMDDevice::isDisplayingWarning()
|
|||
if (!mIsValid || !mDevice)
|
||||
return false;
|
||||
|
||||
return false;/*
|
||||
return false;/*
|
||||
ovrHSWDisplayState displayState;
|
||||
ovrHmd_GetHSWDisplayState(mDevice, &displayState);
|
||||
|
||||
|
|
@ -326,145 +326,145 @@ GFXTexHandle OculusVRHMDDevice::getPreviewTexture()
|
|||
|
||||
bool OculusVRHMDDevice::setupTargets()
|
||||
{
|
||||
// Create eye render buffers
|
||||
ID3D11RenderTargetView * eyeRenderTexRtv[2];
|
||||
ovrLayerEyeFov ld = { { ovrLayerType_EyeFov } };
|
||||
mRenderLayer = ld;
|
||||
// Create eye render buffers
|
||||
ID3D11RenderTargetView * eyeRenderTexRtv[2];
|
||||
ovrLayerEyeFov ld = { { ovrLayerType_EyeFov } };
|
||||
mRenderLayer = ld;
|
||||
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
mRenderLayer.Fov[i] = desc.DefaultEyeFov[i];
|
||||
mRenderLayer.Viewport[i].Size = ovr_GetFovTextureSize(mDevice, (ovrEyeType)i, mRenderLayer.Fov[i], mCurrentPixelDensity);
|
||||
mEyeRenderDesc[i] = ovr_GetRenderDesc(mDevice, (ovrEyeType_)(ovrEye_Left+i), mRenderLayer.Fov[i]);
|
||||
}
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
mRenderLayer.Fov[i] = desc.DefaultEyeFov[i];
|
||||
mRenderLayer.Viewport[i].Size = ovr_GetFovTextureSize(mDevice, (ovrEyeType)i, mRenderLayer.Fov[i], mCurrentPixelDensity);
|
||||
mEyeRenderDesc[i] = ovr_GetRenderDesc(mDevice, (ovrEyeType_)(ovrEye_Left+i), mRenderLayer.Fov[i]);
|
||||
}
|
||||
|
||||
ovrSizei recommendedEyeTargetSize[2];
|
||||
recommendedEyeTargetSize[0] = mRenderLayer.Viewport[0].Size;
|
||||
recommendedEyeTargetSize[1] = mRenderLayer.Viewport[1].Size;
|
||||
ovrSizei recommendedEyeTargetSize[2];
|
||||
recommendedEyeTargetSize[0] = mRenderLayer.Viewport[0].Size;
|
||||
recommendedEyeTargetSize[1] = mRenderLayer.Viewport[1].Size;
|
||||
|
||||
if (mTextureSwapSet)
|
||||
{
|
||||
delete mTextureSwapSet;
|
||||
mTextureSwapSet = NULL;
|
||||
}
|
||||
if (mTextureSwapSet)
|
||||
{
|
||||
delete mTextureSwapSet;
|
||||
mTextureSwapSet = NULL;
|
||||
}
|
||||
|
||||
// Calculate render target size
|
||||
if (mDesiredRenderingMode == GFXDevice::RS_StereoSideBySide)
|
||||
{
|
||||
// Setup a single texture, side-by-side viewports
|
||||
Point2I rtSize(
|
||||
recommendedEyeTargetSize[0].w + recommendedEyeTargetSize[1].w,
|
||||
recommendedEyeTargetSize[0].h > recommendedEyeTargetSize[1].h ? recommendedEyeTargetSize[0].h : recommendedEyeTargetSize[1].h
|
||||
);
|
||||
// Calculate render target size
|
||||
if (mDesiredRenderingMode == GFXDevice::RS_StereoSideBySide)
|
||||
{
|
||||
// Setup a single texture, side-by-side viewports
|
||||
Point2I rtSize(
|
||||
recommendedEyeTargetSize[0].w + recommendedEyeTargetSize[1].w,
|
||||
recommendedEyeTargetSize[0].h > recommendedEyeTargetSize[1].h ? recommendedEyeTargetSize[0].h : recommendedEyeTargetSize[1].h
|
||||
);
|
||||
|
||||
GFXFormat targetFormat = GFX->getActiveRenderTarget()->getFormat();
|
||||
mRTFormat = targetFormat;
|
||||
GFXFormat targetFormat = GFX->getActiveRenderTarget()->getFormat();
|
||||
mRTFormat = targetFormat;
|
||||
|
||||
rtSize = generateRenderTarget(mStereoRT, mStereoDepthTexture, rtSize);
|
||||
rtSize = generateRenderTarget(mStereoRT, mStereoDepthTexture, rtSize);
|
||||
|
||||
// Generate the swap texture we need to store the final image
|
||||
D3D11OculusTexture* tex = new D3D11OculusTexture(GFX);
|
||||
if (tex->Init(mDevice, rtSize.x, rtSize.y))
|
||||
{
|
||||
mTextureSwapSet = tex;
|
||||
}
|
||||
// Generate the swap texture we need to store the final image
|
||||
D3D11OculusTexture* tex = new D3D11OculusTexture(GFX);
|
||||
if (tex->Init(mDevice, rtSize.x, rtSize.y))
|
||||
{
|
||||
mTextureSwapSet = tex;
|
||||
}
|
||||
|
||||
mRenderLayer.ColorTexture[0] = tex->TextureSet;
|
||||
mRenderLayer.ColorTexture[1] = tex->TextureSet;
|
||||
mRenderLayer.ColorTexture[0] = tex->TextureSet;
|
||||
mRenderLayer.ColorTexture[1] = tex->TextureSet;
|
||||
|
||||
mRenderLayer.Viewport[0].Pos.x = 0;
|
||||
mRenderLayer.Viewport[0].Pos.y = 0;
|
||||
mRenderLayer.Viewport[1].Pos.x = (rtSize.x + 1) / 2;
|
||||
mRenderLayer.Viewport[1].Pos.y = 0;
|
||||
mRenderLayer.Viewport[0].Pos.x = 0;
|
||||
mRenderLayer.Viewport[0].Pos.y = 0;
|
||||
mRenderLayer.Viewport[1].Pos.x = (rtSize.x + 1) / 2;
|
||||
mRenderLayer.Viewport[1].Pos.y = 0;
|
||||
|
||||
// Left
|
||||
mEyeRT[0] = mStereoRT;
|
||||
mEyeViewport[0] = RectI(Point2I(mRenderLayer.Viewport[0].Pos.x, mRenderLayer.Viewport[0].Pos.y), Point2I(mRenderLayer.Viewport[0].Size.w, mRenderLayer.Viewport[0].Size.h));
|
||||
// Left
|
||||
mEyeRT[0] = mStereoRT;
|
||||
mEyeViewport[0] = RectI(Point2I(mRenderLayer.Viewport[0].Pos.x, mRenderLayer.Viewport[0].Pos.y), Point2I(mRenderLayer.Viewport[0].Size.w, mRenderLayer.Viewport[0].Size.h));
|
||||
|
||||
// Right
|
||||
mEyeRT[1] = mStereoRT;
|
||||
mEyeViewport[1] = RectI(Point2I(mRenderLayer.Viewport[1].Pos.x, mRenderLayer.Viewport[1].Pos.y), Point2I(mRenderLayer.Viewport[1].Size.w, mRenderLayer.Viewport[1].Size.h));
|
||||
// Right
|
||||
mEyeRT[1] = mStereoRT;
|
||||
mEyeViewport[1] = RectI(Point2I(mRenderLayer.Viewport[1].Pos.x, mRenderLayer.Viewport[1].Pos.y), Point2I(mRenderLayer.Viewport[1].Size.w, mRenderLayer.Viewport[1].Size.h));
|
||||
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
GFXD3D11Device* device = static_cast<GFXD3D11Device*>(GFX);
|
||||
|
||||
D3D11_TEXTURE2D_DESC dsDesc;
|
||||
dsDesc.Width = rtSize.x;
|
||||
dsDesc.Height = rtSize.y;
|
||||
dsDesc.MipLevels = 1;
|
||||
dsDesc.ArraySize = 1;
|
||||
dsDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;// DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
dsDesc.SampleDesc.Count = 1;
|
||||
dsDesc.SampleDesc.Quality = 0;
|
||||
dsDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
dsDesc.CPUAccessFlags = 0;
|
||||
dsDesc.MiscFlags = 0;
|
||||
D3D11_TEXTURE2D_DESC dsDesc;
|
||||
dsDesc.Width = rtSize.x;
|
||||
dsDesc.Height = rtSize.y;
|
||||
dsDesc.MipLevels = 1;
|
||||
dsDesc.ArraySize = 1;
|
||||
dsDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;// DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
dsDesc.SampleDesc.Count = 1;
|
||||
dsDesc.SampleDesc.Quality = 0;
|
||||
dsDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
dsDesc.CPUAccessFlags = 0;
|
||||
dsDesc.MiscFlags = 0;
|
||||
|
||||
// Create typeless when we are rendering as non-sRGB since we will override the texture format in the RTV
|
||||
bool reinterpretSrgbAsLinear = true;
|
||||
unsigned compositorTextureFlags = 0;
|
||||
if (reinterpretSrgbAsLinear)
|
||||
compositorTextureFlags |= ovrSwapTextureSetD3D11_Typeless;
|
||||
// Create typeless when we are rendering as non-sRGB since we will override the texture format in the RTV
|
||||
bool reinterpretSrgbAsLinear = true;
|
||||
unsigned compositorTextureFlags = 0;
|
||||
if (reinterpretSrgbAsLinear)
|
||||
compositorTextureFlags |= ovrSwapTextureSetD3D11_Typeless;
|
||||
|
||||
ovrResult result = ovr_CreateMirrorTextureD3D11(mDevice, device->mD3DDevice, &dsDesc, compositorTextureFlags, &mDebugMirrorTexture);
|
||||
|
||||
if (result == ovrError_DisplayLost || !mDebugMirrorTexture)
|
||||
{
|
||||
AssertFatal(false, "Something went wrong");
|
||||
return NULL;
|
||||
}
|
||||
ovrResult result = ovr_CreateMirrorTextureD3D11(mDevice, device->mD3DDevice, &dsDesc, compositorTextureFlags, &mDebugMirrorTexture);
|
||||
|
||||
if (result == ovrError_DisplayLost || !mDebugMirrorTexture)
|
||||
{
|
||||
AssertFatal(false, "Something went wrong");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Create texture handle so we can render it in-game
|
||||
ovrD3D11Texture* mirror_tex = (ovrD3D11Texture*)mDebugMirrorTexture;
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
|
||||
rtvd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;// DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
// Create texture handle so we can render it in-game
|
||||
ovrD3D11Texture* mirror_tex = (ovrD3D11Texture*)mDebugMirrorTexture;
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvd = {};
|
||||
rtvd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;// DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
rtvd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
GFXD3D11TextureObject* object = new GFXD3D11TextureObject(GFX, &VRTextureProfile);
|
||||
object->registerResourceWithDevice(GFX);
|
||||
*(object->getSRViewPtr()) = mirror_tex->D3D11.pSRView;
|
||||
*(object->get2DTexPtr()) = mirror_tex->D3D11.pTexture;
|
||||
device->mD3DDevice->CreateRenderTargetView(mirror_tex->D3D11.pTexture, &rtvd, object->getRTViewPtr());
|
||||
GFXD3D11TextureObject* object = new GFXD3D11TextureObject(GFX, &VRTextureProfile);
|
||||
object->registerResourceWithDevice(GFX);
|
||||
*(object->getSRViewPtr()) = mirror_tex->D3D11.pSRView;
|
||||
*(object->get2DTexPtr()) = mirror_tex->D3D11.pTexture;
|
||||
device->mD3DDevice->CreateRenderTargetView(mirror_tex->D3D11.pTexture, &rtvd, object->getRTViewPtr());
|
||||
|
||||
|
||||
// Add refs for texture release later on
|
||||
if (object->getSRView()) object->getSRView()->AddRef();
|
||||
//object->getRTView()->AddRef();
|
||||
if (object->get2DTex()) object->get2DTex()->AddRef();
|
||||
object->isManaged = true;
|
||||
// Add refs for texture release later on
|
||||
if (object->getSRView()) object->getSRView()->AddRef();
|
||||
//object->getRTView()->AddRef();
|
||||
if (object->get2DTex()) object->get2DTex()->AddRef();
|
||||
object->isManaged = true;
|
||||
|
||||
// Get the actual size of the texture...
|
||||
D3D11_TEXTURE2D_DESC probeDesc;
|
||||
ZeroMemory(&probeDesc, sizeof(D3D11_TEXTURE2D_DESC));
|
||||
object->get2DTex()->GetDesc(&probeDesc);
|
||||
// Get the actual size of the texture...
|
||||
D3D11_TEXTURE2D_DESC probeDesc;
|
||||
ZeroMemory(&probeDesc, sizeof(D3D11_TEXTURE2D_DESC));
|
||||
object->get2DTex()->GetDesc(&probeDesc);
|
||||
|
||||
object->mTextureSize.set(probeDesc.Width, probeDesc.Height, 0);
|
||||
object->mBitmapSize = object->mTextureSize;
|
||||
int fmt = probeDesc.Format;
|
||||
object->mTextureSize.set(probeDesc.Width, probeDesc.Height, 0);
|
||||
object->mBitmapSize = object->mTextureSize;
|
||||
int fmt = probeDesc.Format;
|
||||
|
||||
if (fmt == DXGI_FORMAT_R8G8B8A8_TYPELESS || fmt == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
object->mFormat = GFXFormatR8G8B8A8; // usual case
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: improve this. this can be very bad.
|
||||
GFXREVERSE_LOOKUP(GFXD3D11TextureFormat, GFXFormat, fmt);
|
||||
object->mFormat = (GFXFormat)fmt;
|
||||
}
|
||||
|
||||
mDebugMirrorTextureHandle = object;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No rendering, abort!
|
||||
return false;
|
||||
}
|
||||
if (fmt == DXGI_FORMAT_R8G8B8A8_TYPELESS || fmt == DXGI_FORMAT_B8G8R8A8_TYPELESS)
|
||||
{
|
||||
object->mFormat = GFXFormatR8G8B8A8; // usual case
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: improve this. this can be very bad.
|
||||
GFXREVERSE_LOOKUP(GFXD3D11TextureFormat, GFXFormat, fmt);
|
||||
object->mFormat = (GFXFormat)fmt;
|
||||
}
|
||||
|
||||
mDebugMirrorTextureHandle = object;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No rendering, abort!
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
String OculusVRHMDDevice::dumpMetrics()
|
||||
|
|
@ -510,17 +510,17 @@ void OculusVRHMDDevice::updateRenderInfo()
|
|||
|
||||
PlatformWindow *window = mDrawCanvas->getPlatformWindow();
|
||||
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(mDevice);
|
||||
|
||||
// Update window size if it's incorrect
|
||||
Point2I backbufferSize = mDrawCanvas->getBounds().extent;
|
||||
|
||||
// Finally setup!
|
||||
if (!setupTargets())
|
||||
{
|
||||
onDeviceDestroy();
|
||||
return;
|
||||
}
|
||||
// Finally setup!
|
||||
if (!setupTargets())
|
||||
{
|
||||
onDeviceDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
mRenderConfigurationDirty = false;
|
||||
}
|
||||
|
|
@ -583,12 +583,12 @@ void OculusVRHMDDevice::clearRenderTargets()
|
|||
mEyeRT[0] = NULL;
|
||||
mEyeRT[1] = NULL;
|
||||
|
||||
if (mDebugMirrorTexture)
|
||||
{
|
||||
ovr_DestroyMirrorTexture(mDevice, mDebugMirrorTexture);
|
||||
mDebugMirrorTexture = NULL;
|
||||
mDebugMirrorTextureHandle = NULL;
|
||||
}
|
||||
if (mDebugMirrorTexture)
|
||||
{
|
||||
ovr_DestroyMirrorTexture(mDevice, mDebugMirrorTexture);
|
||||
mDebugMirrorTexture = NULL;
|
||||
mDebugMirrorTextureHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void OculusVRHMDDevice::updateCaps()
|
||||
|
|
@ -609,21 +609,21 @@ void OculusVRHMDDevice::onStartFrame()
|
|||
sInFrame = true;
|
||||
|
||||
ovrVector3f hmdToEyeViewOffset[2] = { mEyeRenderDesc[0].HmdToEyeViewOffset, mEyeRenderDesc[1].HmdToEyeViewOffset };
|
||||
ovrTrackingState hmdState = ovr_GetTrackingState(mDevice, 0, ovrTrue);
|
||||
ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeViewOffset, mRenderLayer.RenderPose);
|
||||
ovrTrackingState hmdState = ovr_GetTrackingState(mDevice, 0, ovrTrue);
|
||||
ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeViewOffset, mRenderLayer.RenderPose);
|
||||
|
||||
for (U32 i=0; i<2; i++)
|
||||
{
|
||||
mRenderLayer.RenderPose[i].Position.x *= OculusVRDevice::smPositionTrackingScale;
|
||||
mRenderLayer.RenderPose[i].Position.y *= OculusVRDevice::smPositionTrackingScale;
|
||||
mRenderLayer.RenderPose[i].Position.z *= OculusVRDevice::smPositionTrackingScale;
|
||||
mRenderLayer.RenderPose[i].Position.x *= OculusVRDevice::smPositionTrackingScale;
|
||||
mRenderLayer.RenderPose[i].Position.y *= OculusVRDevice::smPositionTrackingScale;
|
||||
mRenderLayer.RenderPose[i].Position.z *= OculusVRDevice::smPositionTrackingScale;
|
||||
}
|
||||
|
||||
mRenderLayer.SensorSampleTime = ovr_GetTimeInSeconds();
|
||||
mRenderLayer.SensorSampleTime = ovr_GetTimeInSeconds();
|
||||
|
||||
// Set current dest texture on stereo render target
|
||||
D3D11OculusTexture* texSwap = (D3D11OculusTexture*)mTextureSwapSet;
|
||||
mStereoRT->attachTexture(GFXTextureTarget::Color0, texSwap->TexRtv[texSwap->TextureSet->CurrentIndex]);
|
||||
// Set current dest texture on stereo render target
|
||||
D3D11OculusTexture* texSwap = (D3D11OculusTexture*)mTextureSwapSet;
|
||||
mStereoRT->attachTexture(GFXTextureTarget::Color0, texSwap->TexRtv[texSwap->TextureSet->CurrentIndex]);
|
||||
|
||||
sInFrame = false;
|
||||
mFrameReady = true;
|
||||
|
|
@ -639,32 +639,32 @@ void OculusVRHMDDevice::onEndFrame()
|
|||
|
||||
GFXD3D11Device *d3d11GFX = dynamic_cast<GFXD3D11Device*>(GFX);
|
||||
|
||||
ovrViewScaleDesc viewScaleDesc;
|
||||
ovrVector3f hmdToEyeViewOffset[2] = { mEyeRenderDesc[0].HmdToEyeViewOffset, mEyeRenderDesc[1].HmdToEyeViewOffset };
|
||||
viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
|
||||
viewScaleDesc.HmdToEyeViewOffset[0] = hmdToEyeViewOffset[0];
|
||||
viewScaleDesc.HmdToEyeViewOffset[1] = hmdToEyeViewOffset[1];
|
||||
ovrViewScaleDesc viewScaleDesc;
|
||||
ovrVector3f hmdToEyeViewOffset[2] = { mEyeRenderDesc[0].HmdToEyeViewOffset, mEyeRenderDesc[1].HmdToEyeViewOffset };
|
||||
viewScaleDesc.HmdSpaceToWorldScaleInMeters = 1.0f;
|
||||
viewScaleDesc.HmdToEyeViewOffset[0] = hmdToEyeViewOffset[0];
|
||||
viewScaleDesc.HmdToEyeViewOffset[1] = hmdToEyeViewOffset[1];
|
||||
|
||||
|
||||
ovrLayerDirect ld = { { ovrLayerType_Direct } };
|
||||
mDebugRenderLayer = ld;
|
||||
ovrLayerDirect ld = { { ovrLayerType_Direct } };
|
||||
mDebugRenderLayer = ld;
|
||||
|
||||
mDebugRenderLayer.ColorTexture[0] = mRenderLayer.ColorTexture[0];
|
||||
mDebugRenderLayer.ColorTexture[1] = mRenderLayer.ColorTexture[1];
|
||||
mDebugRenderLayer.Viewport[0] = mRenderLayer.Viewport[0];
|
||||
mDebugRenderLayer.Viewport[1] = mRenderLayer.Viewport[1];
|
||||
mDebugRenderLayer.ColorTexture[0] = mRenderLayer.ColorTexture[0];
|
||||
mDebugRenderLayer.ColorTexture[1] = mRenderLayer.ColorTexture[1];
|
||||
mDebugRenderLayer.Viewport[0] = mRenderLayer.Viewport[0];
|
||||
mDebugRenderLayer.Viewport[1] = mRenderLayer.Viewport[1];
|
||||
|
||||
// TODO: use ovrViewScaleDesc
|
||||
ovrLayerHeader* layers = &mRenderLayer.Header;
|
||||
ovrResult result = ovr_SubmitFrame(mDevice, 0, &viewScaleDesc, &layers, 1);
|
||||
mTextureSwapSet->AdvanceToNextTexture();
|
||||
// TODO: use ovrViewScaleDesc
|
||||
ovrLayerHeader* layers = &mRenderLayer.Header;
|
||||
ovrResult result = ovr_SubmitFrame(mDevice, 0, &viewScaleDesc, &layers, 1);
|
||||
mTextureSwapSet->AdvanceToNextTexture();
|
||||
|
||||
if (OVR_SUCCESS(result))
|
||||
{
|
||||
int woo = 1;
|
||||
}
|
||||
if (OVR_SUCCESS(result))
|
||||
{
|
||||
int woo = 1;
|
||||
}
|
||||
|
||||
// TODO: render preview in display?
|
||||
// TODO: render preview in display?
|
||||
|
||||
mFrameReady = false;
|
||||
}
|
||||
|
|
@ -700,11 +700,11 @@ void OculusVRHMDDevice::onDeviceDestroy()
|
|||
mEyeRT[1]->zombify();
|
||||
}
|
||||
|
||||
if (mTextureSwapSet)
|
||||
{
|
||||
delete mTextureSwapSet;
|
||||
mTextureSwapSet = NULL;
|
||||
}
|
||||
if (mTextureSwapSet)
|
||||
{
|
||||
delete mTextureSwapSet;
|
||||
mTextureSwapSet = NULL;
|
||||
}
|
||||
|
||||
mStereoRT = NULL;
|
||||
mStereoDepthTexture = NULL;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ protected:
|
|||
OculusVRSensorDevice *mSensor;
|
||||
U32 mActionCodeIndex;
|
||||
|
||||
ovrGraphicsLuid mLuid;
|
||||
ovrGraphicsLuid mLuid;
|
||||
|
||||
protected:
|
||||
void updateRenderInfo();
|
||||
|
|
@ -126,7 +126,7 @@ public:
|
|||
U32 getVersion() const { return mVersion; }
|
||||
|
||||
// Windows display device name used in EnumDisplaySettings/CreateDC
|
||||
const char* getDisplayDeviceType () const { return mDisplayDeviceType.c_str(); }
|
||||
const char* getDisplayDeviceType () const { return mDisplayDeviceType.c_str(); }
|
||||
|
||||
// MacOS display ID
|
||||
S32 getDisplayDeviceId() const { return mDisplayId; }
|
||||
|
|
@ -190,7 +190,7 @@ public:
|
|||
String dumpMetrics();
|
||||
|
||||
// Stereo RT
|
||||
GFXTexHandle mDebugStereoTexture;
|
||||
GFXTexHandle mDebugStereoTexture;
|
||||
GFXTexHandle mStereoDepthTexture;
|
||||
GFXTextureTargetRef mStereoRT;
|
||||
|
||||
|
|
@ -204,12 +204,12 @@ public:
|
|||
F32 smDesiredPixelDensity;
|
||||
|
||||
ovrTrackingState mLastTrackingState;
|
||||
OculusTexture* mTextureSwapSet;
|
||||
ovrLayerEyeFov mRenderLayer;
|
||||
ovrLayerDirect mDebugRenderLayer;
|
||||
ovrViewScaleDesc mScaleDesc;
|
||||
ovrTexture* mDebugMirrorTexture;
|
||||
GFXTexHandle mDebugMirrorTextureHandle;
|
||||
OculusTexture* mTextureSwapSet;
|
||||
ovrLayerEyeFov mRenderLayer;
|
||||
ovrLayerDirect mDebugRenderLayer;
|
||||
ovrViewScaleDesc mScaleDesc;
|
||||
ovrTexture* mDebugMirrorTexture;
|
||||
GFXTexHandle mDebugMirrorTextureHandle;
|
||||
|
||||
GFXDevice::GFXDeviceRenderStyles mDesiredRenderingMode;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ bool OpenVROverlay::onAdd()
|
|||
mOverlayTypeDirty = true;
|
||||
mOverlayDirty = true;
|
||||
|
||||
if (OPENVR)
|
||||
{
|
||||
OPENVR->registerOverlay(this);
|
||||
}
|
||||
if (OPENVR)
|
||||
{
|
||||
OPENVR->registerOverlay(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -127,10 +127,10 @@ void OpenVROverlay::onRemove()
|
|||
mThumbOverlayHandle = NULL;
|
||||
}
|
||||
|
||||
if (ManagedSingleton<OpenVRProvider>::instanceOrNull())
|
||||
{
|
||||
OPENVR->unregisterOverlay(this);
|
||||
}
|
||||
if (ManagedSingleton<OpenVRProvider>::instanceOrNull())
|
||||
{
|
||||
OPENVR->unregisterOverlay(this);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenVROverlay::resetOverlay()
|
||||
|
|
@ -233,14 +233,14 @@ void OpenVROverlay::showOverlay()
|
|||
if (mOverlayHandle == NULL)
|
||||
return;
|
||||
|
||||
if (mOverlayType != OVERLAYTYPE_DASHBOARD)
|
||||
{
|
||||
vr::EVROverlayError err = vr::VROverlay()->ShowOverlay(mOverlayHandle);
|
||||
if (err != vr::VROverlayError_None)
|
||||
{
|
||||
Con::errorf("VR Overlay error!");
|
||||
}
|
||||
}
|
||||
if (mOverlayType != OVERLAYTYPE_DASHBOARD)
|
||||
{
|
||||
vr::EVROverlayError err = vr::VROverlay()->ShowOverlay(mOverlayHandle);
|
||||
if (err != vr::VROverlayError_None)
|
||||
{
|
||||
Con::errorf("VR Overlay error!");
|
||||
}
|
||||
}
|
||||
|
||||
if (!mStagingTexture)
|
||||
{
|
||||
|
|
@ -253,10 +253,10 @@ void OpenVROverlay::hideOverlay()
|
|||
if (mOverlayHandle == NULL)
|
||||
return;
|
||||
|
||||
if (mOverlayType != OVERLAYTYPE_DASHBOARD)
|
||||
{
|
||||
vr::VROverlay()->HideOverlay(mOverlayHandle);
|
||||
}
|
||||
if (mOverlayType != OVERLAYTYPE_DASHBOARD)
|
||||
{
|
||||
vr::VROverlay()->HideOverlay(mOverlayHandle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -317,8 +317,8 @@ bool OpenVROverlay::castRay(const Point3F &origin, const Point3F &direction, Ray
|
|||
vr::VROverlayIntersectionParams_t params;
|
||||
vr::VROverlayIntersectionResults_t result;
|
||||
|
||||
Point3F ovrOrigin = OpenVRUtil::convertPointToOVR(origin);
|
||||
Point3F ovrDirection = OpenVRUtil::convertPointToOVR(direction);
|
||||
Point3F ovrOrigin = OpenVRUtil::convertPointToOVR(origin);
|
||||
Point3F ovrDirection = OpenVRUtil::convertPointToOVR(direction);
|
||||
|
||||
params.eOrigin = mTrackingOrigin;
|
||||
params.vSource.v[0] = ovrOrigin.x;
|
||||
|
|
@ -350,17 +350,17 @@ void OpenVROverlay::moveGamepadFocusToNeighbour()
|
|||
|
||||
void OpenVROverlay::handleOpenVREvents()
|
||||
{
|
||||
if (mManualMouseHandling)
|
||||
{
|
||||
// tell OpenVR to make some events for us
|
||||
for (vr::TrackedDeviceIndex_t unDeviceId = 1; unDeviceId < vr::k_unControllerStateAxisCount; unDeviceId++)
|
||||
{
|
||||
if (vr::VROverlay()->HandleControllerOverlayInteractionAsMouse(mOverlayHandle, unDeviceId))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mManualMouseHandling)
|
||||
{
|
||||
// tell OpenVR to make some events for us
|
||||
for (vr::TrackedDeviceIndex_t unDeviceId = 1; unDeviceId < vr::k_unControllerStateAxisCount; unDeviceId++)
|
||||
{
|
||||
if (vr::VROverlay()->HandleControllerOverlayInteractionAsMouse(mOverlayHandle, unDeviceId))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vr::VREvent_t vrEvent;
|
||||
|
|
@ -373,13 +373,13 @@ void OpenVROverlay::handleOpenVREvents()
|
|||
eventInfo.modifier = (InputModifiers)0;
|
||||
eventInfo.ascii = 0;
|
||||
|
||||
//Con::printf("Overlay event %i", vrEvent.eventType);
|
||||
//Con::printf("Overlay event %i", vrEvent.eventType);
|
||||
|
||||
switch (vrEvent.eventType)
|
||||
{
|
||||
case vr::VREvent_MouseMove:
|
||||
{
|
||||
//Con::printf("mousemove %f,%f", vrEvent.data.mouse.x, vrEvent.data.mouse.y);
|
||||
//Con::printf("mousemove %f,%f", vrEvent.data.mouse.x, vrEvent.data.mouse.y);
|
||||
eventInfo.objType = SI_AXIS;
|
||||
eventInfo.objInst = SI_XAXIS;
|
||||
eventInfo.action = SI_MAKE;
|
||||
|
|
@ -424,11 +424,11 @@ void OpenVROverlay::handleOpenVREvents()
|
|||
AssertFatal(false, "WTF is going on here");
|
||||
break;
|
||||
|
||||
case vr::VREvent_KeyboardCharInput:
|
||||
case vr::VREvent_KeyboardDone:
|
||||
updateTextControl((GuiControl*)vrEvent.data.keyboard.uUserValue);
|
||||
break;
|
||||
}
|
||||
case vr::VREvent_KeyboardCharInput:
|
||||
case vr::VREvent_KeyboardDone:
|
||||
updateTextControl((GuiControl*)vrEvent.data.keyboard.uUserValue);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -450,16 +450,16 @@ void OpenVROverlay::handleOpenVREvents()
|
|||
|
||||
void OpenVROverlay::updateTextControl(GuiControl* ctrl)
|
||||
{
|
||||
if (!ctrl)
|
||||
return;
|
||||
if (!ctrl)
|
||||
return;
|
||||
|
||||
GuiTextCtrl* textCtrl = dynamic_cast<GuiTextCtrl*>(ctrl);
|
||||
if (textCtrl)
|
||||
{
|
||||
char text[GuiTextCtrl::MAX_STRING_LENGTH];
|
||||
vr::VROverlay()->GetKeyboardText(text, GuiTextCtrl::MAX_STRING_LENGTH);
|
||||
textCtrl->setText(text);
|
||||
}
|
||||
GuiTextCtrl* textCtrl = dynamic_cast<GuiTextCtrl*>(ctrl);
|
||||
if (textCtrl)
|
||||
{
|
||||
char text[GuiTextCtrl::MAX_STRING_LENGTH];
|
||||
vr::VROverlay()->GetKeyboardText(text, GuiTextCtrl::MAX_STRING_LENGTH);
|
||||
textCtrl->setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenVROverlay::onFrameRendered()
|
||||
|
|
@ -508,27 +508,27 @@ void OpenVROverlay::onFrameRendered()
|
|||
|
||||
void OpenVROverlay::enableKeyboardTranslation()
|
||||
{
|
||||
vr::IVROverlay *overlay = vr::VROverlay();
|
||||
if (!overlay || !mOverlayHandle)
|
||||
return;
|
||||
vr::IVROverlay *overlay = vr::VROverlay();
|
||||
if (!overlay || !mOverlayHandle)
|
||||
return;
|
||||
|
||||
GuiTextEditCtrl* ctrl = dynamic_cast<GuiTextEditCtrl*>(getFirstResponder());
|
||||
if (ctrl)
|
||||
{
|
||||
vr::EGamepadTextInputMode inputMode = ctrl->isPasswordText() ? vr::k_EGamepadTextInputModePassword : vr::k_EGamepadTextInputModeNormal;
|
||||
char text[GuiTextCtrl::MAX_STRING_LENGTH + 1];
|
||||
ctrl->getText(text);
|
||||
overlay->ShowKeyboardForOverlay(mOverlayHandle, inputMode, vr::k_EGamepadTextInputLineModeSingleLine, ctrl->getTooltip().c_str(), GuiTextCtrl::MAX_STRING_LENGTH, text, false, (uint64_t)ctrl);
|
||||
}
|
||||
GuiTextEditCtrl* ctrl = dynamic_cast<GuiTextEditCtrl*>(getFirstResponder());
|
||||
if (ctrl)
|
||||
{
|
||||
vr::EGamepadTextInputMode inputMode = ctrl->isPasswordText() ? vr::k_EGamepadTextInputModePassword : vr::k_EGamepadTextInputModeNormal;
|
||||
char text[GuiTextCtrl::MAX_STRING_LENGTH + 1];
|
||||
ctrl->getText(text);
|
||||
overlay->ShowKeyboardForOverlay(mOverlayHandle, inputMode, vr::k_EGamepadTextInputLineModeSingleLine, ctrl->getTooltip().c_str(), GuiTextCtrl::MAX_STRING_LENGTH, text, false, (uint64_t)ctrl);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenVROverlay::disableKeyboardTranslation()
|
||||
{
|
||||
vr::IVROverlay *overlay = vr::VROverlay();
|
||||
if (!overlay || !mOverlayHandle)
|
||||
return;
|
||||
vr::IVROverlay *overlay = vr::VROverlay();
|
||||
if (!overlay || !mOverlayHandle)
|
||||
return;
|
||||
|
||||
overlay->HideKeyboard();
|
||||
overlay->HideKeyboard();
|
||||
}
|
||||
|
||||
void OpenVROverlay::setNativeAcceleratorsEnabled(bool enabled)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
bool mOverlayTypeDirty; ///< Overlay type is dirty
|
||||
bool mOverlayDirty; ///< Overlay properties are dirty
|
||||
bool mManualMouseHandling;
|
||||
bool mManualMouseHandling;
|
||||
OverlayType mOverlayType;
|
||||
|
||||
//
|
||||
|
|
@ -90,12 +90,12 @@ public:
|
|||
void moveGamepadFocusToNeighbour();
|
||||
|
||||
void handleOpenVREvents();
|
||||
void updateTextControl(GuiControl* ctrl);
|
||||
void updateTextControl(GuiControl* ctrl);
|
||||
void onFrameRendered();
|
||||
|
||||
virtual void enableKeyboardTranslation();
|
||||
virtual void disableKeyboardTranslation();
|
||||
virtual void setNativeAcceleratorsEnabled(bool enabled);
|
||||
virtual void enableKeyboardTranslation();
|
||||
virtual void disableKeyboardTranslation();
|
||||
virtual void setNativeAcceleratorsEnabled(bool enabled);
|
||||
};
|
||||
|
||||
typedef OpenVROverlay::OverlayType OpenVROverlayType;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -62,91 +62,91 @@ namespace OpenVRUtil
|
|||
|
||||
U32 convertOpenVRButtonToTorqueButton(uint32_t vrButton);
|
||||
|
||||
/// Converts a point to OVR coords
|
||||
inline Point3F convertPointToOVR(const Point3F &point)
|
||||
{
|
||||
return Point3F(-point.x, -point.z, point.y);
|
||||
}
|
||||
/// Converts a point to OVR coords
|
||||
inline Point3F convertPointToOVR(const Point3F &point)
|
||||
{
|
||||
return Point3F(-point.x, -point.z, point.y);
|
||||
}
|
||||
|
||||
/// Converts a point from OVR coords
|
||||
inline Point3F convertPointFromOVR(const Point3F &point)
|
||||
{
|
||||
return Point3F(-point.x, point.z, -point.y);
|
||||
}
|
||||
/// Converts a point from OVR coords
|
||||
inline Point3F convertPointFromOVR(const Point3F &point)
|
||||
{
|
||||
return Point3F(-point.x, point.z, -point.y);
|
||||
}
|
||||
|
||||
// Converts a point from OVR coords, from an input float array
|
||||
inline Point3F convertPointFromOVR(const vr::HmdVector3_t& v)
|
||||
{
|
||||
return Point3F(-v.v[0], v.v[2], -v.v[1]);
|
||||
}
|
||||
// Converts a point from OVR coords, from an input float array
|
||||
inline Point3F convertPointFromOVR(const vr::HmdVector3_t& v)
|
||||
{
|
||||
return Point3F(-v.v[0], v.v[2], -v.v[1]);
|
||||
}
|
||||
};
|
||||
|
||||
template<int TEXSIZE> class VRTextureSet
|
||||
{
|
||||
public:
|
||||
static const int TextureCount = TEXSIZE;
|
||||
GFXTexHandle mTextures[TEXSIZE];
|
||||
U32 mIndex;
|
||||
static const int TextureCount = TEXSIZE;
|
||||
GFXTexHandle mTextures[TEXSIZE];
|
||||
U32 mIndex;
|
||||
|
||||
VRTextureSet() : mIndex(0)
|
||||
{
|
||||
}
|
||||
VRTextureSet() : mIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
void init(U32 width, U32 height, GFXFormat fmt, GFXTextureProfile *profile, const String &desc)
|
||||
{
|
||||
for (U32 i = 0; i < TextureCount; i++)
|
||||
{
|
||||
mTextures[i].set(width, height, fmt, profile, desc);
|
||||
}
|
||||
}
|
||||
void init(U32 width, U32 height, GFXFormat fmt, GFXTextureProfile *profile, const String &desc)
|
||||
{
|
||||
for (U32 i = 0; i < TextureCount; i++)
|
||||
{
|
||||
mTextures[i].set(width, height, fmt, profile, desc);
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
for (U32 i = 0; i < TextureCount; i++)
|
||||
{
|
||||
mTextures[i] = NULL;
|
||||
}
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
for (U32 i = 0; i < TextureCount; i++)
|
||||
{
|
||||
mTextures[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void advance()
|
||||
{
|
||||
mIndex = (mIndex + 1) % TextureCount;
|
||||
}
|
||||
void advance()
|
||||
{
|
||||
mIndex = (mIndex + 1) % TextureCount;
|
||||
}
|
||||
|
||||
GFXTexHandle& getTextureHandle()
|
||||
{
|
||||
return mTextures[mIndex];
|
||||
}
|
||||
GFXTexHandle& getTextureHandle()
|
||||
{
|
||||
return mTextures[mIndex];
|
||||
}
|
||||
};
|
||||
|
||||
/// Simple class to handle rendering native OpenVR model data
|
||||
class OpenVRRenderModel
|
||||
{
|
||||
public:
|
||||
typedef GFXVertexPNT VertexType;
|
||||
GFXVertexBufferHandle<VertexType> mVertexBuffer;
|
||||
GFXPrimitiveBufferHandle mPrimitiveBuffer;
|
||||
BaseMatInstance* mMaterialInstance; ///< Material to use for rendering. NOTE:
|
||||
Box3F mLocalBox;
|
||||
typedef GFXVertexPNT VertexType;
|
||||
GFXVertexBufferHandle<VertexType> mVertexBuffer;
|
||||
GFXPrimitiveBufferHandle mPrimitiveBuffer;
|
||||
BaseMatInstance* mMaterialInstance; ///< Material to use for rendering. NOTE:
|
||||
Box3F mLocalBox;
|
||||
|
||||
OpenVRRenderModel() : mMaterialInstance(NULL)
|
||||
{
|
||||
}
|
||||
OpenVRRenderModel() : mMaterialInstance(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~OpenVRRenderModel()
|
||||
{
|
||||
SAFE_DELETE(mMaterialInstance);
|
||||
}
|
||||
~OpenVRRenderModel()
|
||||
{
|
||||
SAFE_DELETE(mMaterialInstance);
|
||||
}
|
||||
|
||||
Box3F getWorldBox(MatrixF &mat)
|
||||
{
|
||||
Box3F ret = mLocalBox;
|
||||
mat.mul(ret);
|
||||
return ret;
|
||||
}
|
||||
Box3F getWorldBox(MatrixF &mat)
|
||||
{
|
||||
Box3F ret = mLocalBox;
|
||||
mat.mul(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool init(const vr::RenderModel_t & vrModel, StringTableEntry materialName);
|
||||
void draw(SceneRenderState *state, MeshRenderInst* renderInstance);
|
||||
bool init(const vr::RenderModel_t & vrModel, StringTableEntry materialName);
|
||||
void draw(SceneRenderState *state, MeshRenderInst* renderInstance);
|
||||
};
|
||||
|
||||
struct OpenVRRenderState
|
||||
|
|
@ -196,21 +196,21 @@ public:
|
|||
|
||||
struct LoadedRenderModel
|
||||
{
|
||||
StringTableEntry name;
|
||||
vr::RenderModel_t *vrModel;
|
||||
OpenVRRenderModel *model;
|
||||
vr::EVRRenderModelError modelError;
|
||||
S32 textureId;
|
||||
bool loadedTexture;
|
||||
StringTableEntry name;
|
||||
vr::RenderModel_t *vrModel;
|
||||
OpenVRRenderModel *model;
|
||||
vr::EVRRenderModelError modelError;
|
||||
S32 textureId;
|
||||
bool loadedTexture;
|
||||
};
|
||||
|
||||
struct LoadedRenderTexture
|
||||
{
|
||||
U32 vrTextureId;
|
||||
vr::RenderModel_TextureMap_t *vrTexture;
|
||||
GFXTextureObject *texture;
|
||||
NamedTexTarget *targetTexture;
|
||||
vr::EVRRenderModelError textureError;
|
||||
U32 vrTextureId;
|
||||
vr::RenderModel_TextureMap_t *vrTexture;
|
||||
GFXTextureObject *texture;
|
||||
NamedTexTarget *targetTexture;
|
||||
vr::EVRRenderModelError textureError;
|
||||
};
|
||||
|
||||
OpenVRProvider();
|
||||
|
|
@ -283,21 +283,21 @@ public:
|
|||
IDevicePose getTrackedDevicePose(U32 idx);
|
||||
/// }
|
||||
|
||||
/// @name Overlay registration
|
||||
/// {
|
||||
void registerOverlay(OpenVROverlay* overlay);
|
||||
void unregisterOverlay(OpenVROverlay* overlay);
|
||||
/// }
|
||||
/// @name Overlay registration
|
||||
/// {
|
||||
void registerOverlay(OpenVROverlay* overlay);
|
||||
void unregisterOverlay(OpenVROverlay* overlay);
|
||||
/// }
|
||||
|
||||
/// @name Model loading
|
||||
/// {
|
||||
const S32 preloadRenderModel(StringTableEntry name);
|
||||
const S32 preloadRenderModelTexture(U32 index);
|
||||
bool getRenderModel(S32 idx, OpenVRRenderModel **ret, bool &failed);
|
||||
bool getRenderModelTexture(S32 idx, GFXTextureObject **outTex, bool &failed);
|
||||
bool getRenderModelTextureName(S32 idx, String &outName);
|
||||
void resetRenderModels();
|
||||
/// }
|
||||
/// @name Model loading
|
||||
/// {
|
||||
const S32 preloadRenderModel(StringTableEntry name);
|
||||
const S32 preloadRenderModelTexture(U32 index);
|
||||
bool getRenderModel(S32 idx, OpenVRRenderModel **ret, bool &failed);
|
||||
bool getRenderModelTexture(S32 idx, GFXTextureObject **outTex, bool &failed);
|
||||
bool getRenderModelTextureName(S32 idx, String &outName);
|
||||
void resetRenderModels();
|
||||
/// }
|
||||
|
||||
|
||||
/// @name Console API
|
||||
|
|
@ -338,17 +338,17 @@ public:
|
|||
|
||||
vr::ETrackingUniverseOrigin mTrackingSpace;
|
||||
|
||||
Vector<OpenVROverlay*> mOverlays;
|
||||
Vector<OpenVROverlay*> mOverlays;
|
||||
|
||||
VREventSignal mVREventSignal;
|
||||
Namespace *mOpenVRNS;
|
||||
VREventSignal mVREventSignal;
|
||||
Namespace *mOpenVRNS;
|
||||
|
||||
Vector<LoadedRenderModel> mLoadedModels;
|
||||
Vector<LoadedRenderTexture> mLoadedTextures;
|
||||
Map<StringTableEntry, S32> mLoadedModelLookup;
|
||||
Map<U32, S32> mLoadedTextureLookup;
|
||||
Vector<LoadedRenderModel> mLoadedModels;
|
||||
Vector<LoadedRenderTexture> mLoadedTextures;
|
||||
Map<StringTableEntry, S32> mLoadedModelLookup;
|
||||
Map<U32, S32> mLoadedTextureLookup;
|
||||
|
||||
Map<U32, S32> mDeviceEventMap;
|
||||
Map<U32, S32> mDeviceEventMap;
|
||||
/// }
|
||||
|
||||
GuiCanvas* mDrawCanvas;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -23,132 +23,132 @@ class PhysicsBody;
|
|||
|
||||
class OpenVRTrackedObjectData : public GameBaseData {
|
||||
public:
|
||||
typedef GameBaseData Parent;
|
||||
typedef GameBaseData Parent;
|
||||
|
||||
StringTableEntry mShapeFile;
|
||||
Resource<TSShape> mShape; ///< Torque model
|
||||
StringTableEntry mShapeFile;
|
||||
Resource<TSShape> mShape; ///< Torque model
|
||||
|
||||
Point3F mCollisionBoxMin;
|
||||
Point3F mCollisionBoxMax;
|
||||
Point3F mCollisionBoxMin;
|
||||
Point3F mCollisionBoxMax;
|
||||
|
||||
public:
|
||||
|
||||
OpenVRTrackedObjectData();
|
||||
~OpenVRTrackedObjectData();
|
||||
OpenVRTrackedObjectData();
|
||||
~OpenVRTrackedObjectData();
|
||||
|
||||
DECLARE_CONOBJECT(OpenVRTrackedObjectData);
|
||||
DECLARE_CONOBJECT(OpenVRTrackedObjectData);
|
||||
|
||||
bool onAdd();
|
||||
bool preload(bool server, String &errorStr);
|
||||
bool onAdd();
|
||||
bool preload(bool server, String &errorStr);
|
||||
|
||||
static void initPersistFields();
|
||||
static void initPersistFields();
|
||||
|
||||
virtual void packData(BitStream* stream);
|
||||
virtual void unpackData(BitStream* stream);
|
||||
virtual void packData(BitStream* stream);
|
||||
virtual void unpackData(BitStream* stream);
|
||||
};
|
||||
|
||||
/// Implements a GameObject which tracks an OpenVR controller
|
||||
class OpenVRTrackedObject : public GameBase
|
||||
{
|
||||
typedef GameBase Parent;
|
||||
typedef GameBase Parent;
|
||||
|
||||
enum MaskBits
|
||||
{
|
||||
UpdateMask = Parent::NextFreeMask << 0,
|
||||
NextFreeMask = Parent::NextFreeMask << 1
|
||||
};
|
||||
enum MaskBits
|
||||
{
|
||||
UpdateMask = Parent::NextFreeMask << 0,
|
||||
NextFreeMask = Parent::NextFreeMask << 1
|
||||
};
|
||||
|
||||
struct RenderModelSlot
|
||||
{
|
||||
StringTableEntry componentName; ///< Component name
|
||||
S16 mappedNodeIdx; ///< Mapped node idx in mShape
|
||||
OpenVRRenderModel *nativeModel; ///< Native model
|
||||
};
|
||||
struct RenderModelSlot
|
||||
{
|
||||
StringTableEntry componentName; ///< Component name
|
||||
S16 mappedNodeIdx; ///< Mapped node idx in mShape
|
||||
OpenVRRenderModel *nativeModel; ///< Native model
|
||||
};
|
||||
|
||||
OpenVRTrackedObjectData *mDataBlock;
|
||||
OpenVRTrackedObjectData *mDataBlock;
|
||||
|
||||
/// @name Rendering
|
||||
/// {
|
||||
TSShapeInstance *mShapeInstance; ///< Shape used to render controller (uses native model otherwise)
|
||||
StringTableEntry mModelName;
|
||||
OpenVRRenderModel *mBasicModel; ///< Basic model
|
||||
Vector<RenderModelSlot> mRenderComponents;
|
||||
/// }
|
||||
/// @name Rendering
|
||||
/// {
|
||||
TSShapeInstance *mShapeInstance; ///< Shape used to render controller (uses native model otherwise)
|
||||
StringTableEntry mModelName;
|
||||
OpenVRRenderModel *mBasicModel; ///< Basic model
|
||||
Vector<RenderModelSlot> mRenderComponents;
|
||||
/// }
|
||||
|
||||
S32 mDeviceIndex; ///< Controller idx in openvr (for direct updating)
|
||||
S32 mMappedMoveIndex; ///< Movemanager move index for rotation
|
||||
S32 mDeviceIndex; ///< Controller idx in openvr (for direct updating)
|
||||
S32 mMappedMoveIndex; ///< Movemanager move index for rotation
|
||||
|
||||
vr::VRControllerState_t mCurrentControllerState;
|
||||
vr::VRControllerState_t mPreviousControllerState;
|
||||
vr::VRControllerState_t mCurrentControllerState;
|
||||
vr::VRControllerState_t mPreviousControllerState;
|
||||
|
||||
IDevicePose mPose; ///< Current openvr pose data, or reconstructed data from the client
|
||||
IDevicePose mPose; ///< Current openvr pose data, or reconstructed data from the client
|
||||
|
||||
Convex* mConvexList;
|
||||
EarlyOutPolyList mClippedList;
|
||||
PhysicsBody *mPhysicsRep;
|
||||
Convex* mConvexList;
|
||||
EarlyOutPolyList mClippedList;
|
||||
PhysicsBody *mPhysicsRep;
|
||||
|
||||
SimObjectPtr<SceneObject> mCollisionObject; ///< Object we're currently colliding with
|
||||
SimObjectPtr<SceneObject> mInteractObject; ///< Object we've designated as important to interact with
|
||||
SimObjectPtr<SceneObject> mCollisionObject; ///< Object we're currently colliding with
|
||||
SimObjectPtr<SceneObject> mInteractObject; ///< Object we've designated as important to interact with
|
||||
|
||||
bool mHoldInteractedObject; ///< Performs pickup logic with mInteractObject
|
||||
bool mIgnoreParentRotation; ///< Ignores the rotation of the parent object
|
||||
bool mHoldInteractedObject; ///< Performs pickup logic with mInteractObject
|
||||
bool mIgnoreParentRotation; ///< Ignores the rotation of the parent object
|
||||
|
||||
static bool smDebugControllerPosition; ///< Shows latest controller position in DebugDrawer
|
||||
static bool smDebugControllerMovePosition; ///< Shows move position in DebugDrawer
|
||||
static U32 sServerCollisionMask;
|
||||
static U32 sClientCollisionMask;
|
||||
static bool smDebugControllerPosition; ///< Shows latest controller position in DebugDrawer
|
||||
static bool smDebugControllerMovePosition; ///< Shows move position in DebugDrawer
|
||||
static U32 sServerCollisionMask;
|
||||
static U32 sClientCollisionMask;
|
||||
|
||||
public:
|
||||
OpenVRTrackedObject();
|
||||
virtual ~OpenVRTrackedObject();
|
||||
OpenVRTrackedObject();
|
||||
virtual ~OpenVRTrackedObject();
|
||||
|
||||
void updateRenderData();
|
||||
void setupRenderDataFromModel(bool loadComponentModels);
|
||||
void updateRenderData();
|
||||
void setupRenderDataFromModel(bool loadComponentModels);
|
||||
|
||||
void clearRenderData();
|
||||
void clearRenderData();
|
||||
|
||||
DECLARE_CONOBJECT(OpenVRTrackedObject);
|
||||
DECLARE_CONOBJECT(OpenVRTrackedObject);
|
||||
|
||||
static void initPersistFields();
|
||||
static void initPersistFields();
|
||||
|
||||
virtual void inspectPostApply();
|
||||
virtual void inspectPostApply();
|
||||
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
|
||||
|
||||
void _updatePhysics();
|
||||
bool onNewDataBlock(GameBaseData *dptr, bool reload);
|
||||
void _updatePhysics();
|
||||
bool onNewDataBlock(GameBaseData *dptr, bool reload);
|
||||
|
||||
void setInteractObject(SceneObject* object, bool holding);
|
||||
void setInteractObject(SceneObject* object, bool holding);
|
||||
|
||||
void setTransform(const MatrixF &mat);
|
||||
void setModelName(String &modelName);
|
||||
void setTransform(const MatrixF &mat);
|
||||
void setModelName(String &modelName);
|
||||
|
||||
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
|
||||
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
||||
void writePacketData(GameConnection *conn, BitStream *stream);
|
||||
void readPacketData(GameConnection *conn, BitStream *stream);
|
||||
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
|
||||
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
||||
void writePacketData(GameConnection *conn, BitStream *stream);
|
||||
void readPacketData(GameConnection *conn, BitStream *stream);
|
||||
|
||||
void prepRenderImage(SceneRenderState *state);
|
||||
void prepRenderImage(SceneRenderState *state);
|
||||
|
||||
MatrixF getTrackedTransform();
|
||||
MatrixF getLastTrackedTransform();
|
||||
MatrixF getBaseTrackingTransform();
|
||||
MatrixF getTrackedTransform();
|
||||
MatrixF getLastTrackedTransform();
|
||||
MatrixF getBaseTrackingTransform();
|
||||
|
||||
U32 getCollisionMask();
|
||||
void updateWorkingCollisionSet();
|
||||
U32 getCollisionMask();
|
||||
void updateWorkingCollisionSet();
|
||||
|
||||
// Time management
|
||||
void updateMove(const Move *move);
|
||||
void processTick(const Move *move);
|
||||
void interpolateTick(F32 delta);
|
||||
void advanceTime(F32 dt);
|
||||
// Time management
|
||||
void updateMove(const Move *move);
|
||||
void processTick(const Move *move);
|
||||
void interpolateTick(F32 delta);
|
||||
void advanceTime(F32 dt);
|
||||
|
||||
// Collision
|
||||
bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
void buildConvex(const Box3F& box, Convex* convex);
|
||||
bool testObject(SceneObject* enter);
|
||||
// Collision
|
||||
bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
void buildConvex(const Box3F& box, Convex* convex);
|
||||
bool testObject(SceneObject* enter);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue