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