mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 21:05:04 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into fix-include-race
This commit is contained in:
commit
d73fc1681c
20 changed files with 320 additions and 29 deletions
|
@ -386,8 +386,11 @@ bool AudioMixer::prepareMixForListeningNode(Node* node) {
|
||||||
// loop through all other nodes that have sufficient audio to mix
|
// loop through all other nodes that have sufficient audio to mix
|
||||||
|
|
||||||
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& otherNode){
|
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& otherNode){
|
||||||
// make sure that we have audio data for this other node and that it isn't being ignored by our listening node
|
// make sure that we have audio data for this other node
|
||||||
if (otherNode->getLinkedData() && !node->isIgnoringNodeWithID(otherNode->getUUID())) {
|
// and that it isn't being ignored by our listening node
|
||||||
|
// and that it isn't ignoring our listening node
|
||||||
|
if (otherNode->getLinkedData()
|
||||||
|
&& !node->isIgnoringNodeWithID(otherNode->getUUID()) && !otherNode->isIgnoringNodeWithID(node->getUUID())) {
|
||||||
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
AudioMixerClientData* otherNodeClientData = (AudioMixerClientData*) otherNode->getLinkedData();
|
||||||
|
|
||||||
// enumerate the ARBs attached to the otherNode and add all that should be added to mix
|
// enumerate the ARBs attached to the otherNode and add all that should be added to mix
|
||||||
|
|
|
@ -230,9 +230,11 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
[&](const SharedNodePointer& otherNode)->bool {
|
[&](const SharedNodePointer& otherNode)->bool {
|
||||||
// make sure we have data for this avatar, that it isn't the same node,
|
// make sure we have data for this avatar, that it isn't the same node,
|
||||||
// and isn't an avatar that the viewing node has ignored
|
// and isn't an avatar that the viewing node has ignored
|
||||||
|
// or that has ignored the viewing node
|
||||||
if (!otherNode->getLinkedData()
|
if (!otherNode->getLinkedData()
|
||||||
|| otherNode->getUUID() == node->getUUID()
|
|| otherNode->getUUID() == node->getUUID()
|
||||||
|| node->isIgnoringNodeWithID(otherNode->getUUID())) {
|
|| node->isIgnoringNodeWithID(otherNode->getUUID())
|
||||||
|
|| otherNode->isIgnoringNodeWithID(node->getUUID())) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 84 KiB |
|
@ -50,7 +50,8 @@ QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
valid = true;
|
valid = true;
|
||||||
override = false;
|
override = false;
|
||||||
|
|
||||||
QGLWidget* glWidget = new QGLWidget();
|
QGLWidget* glWidget = new QGLWidget(getDefaultGLFormat());
|
||||||
|
|
||||||
valid = glWidget->isValid();
|
valid = glWidget->isValid();
|
||||||
// Inform user if no OpenGL support
|
// Inform user if no OpenGL support
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
|
|
|
@ -307,11 +307,20 @@ void GLBackend::render(const Batch& batch) {
|
||||||
renderPassTransfer(batch);
|
renderPassTransfer(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
if (_stereo._enable) {
|
||||||
|
glEnable(GL_CLIP_DISTANCE0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(_stereo._enable ? "Render Stereo" : "Render");
|
PROFILE_RANGE(_stereo._enable ? "Render Stereo" : "Render");
|
||||||
renderPassDraw(batch);
|
renderPassDraw(batch);
|
||||||
}
|
}
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
if (_stereo._enable) {
|
||||||
|
glDisable(GL_CLIP_DISTANCE0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
// Restore the saved stereo state for the next batch
|
// Restore the saved stereo state for the next batch
|
||||||
_stereo._enable = savedStereo;
|
_stereo._enable = savedStereo;
|
||||||
}
|
}
|
||||||
|
@ -326,13 +335,24 @@ void GLBackend::syncCache() {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
void GLBackend::setupStereoSide(int side) {
|
void GLBackend::setupStereoSide(int side) {
|
||||||
ivec4 vp = _transform._viewport;
|
ivec4 vp = _transform._viewport;
|
||||||
vp.z /= 2;
|
vp.z /= 2;
|
||||||
glViewport(vp.x + side * vp.z, vp.y, vp.z, vp.w);
|
glViewport(vp.x + side * vp.z, vp.y, vp.z, vp.w);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
|
glVertexAttribI1i(14, side);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
_transform.bindCurrentCamera(side);
|
_transform.bindCurrentCamera(side);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
|
||||||
void GLBackend::do_resetStages(const Batch& batch, size_t paramOffset) {
|
void GLBackend::do_resetStages(const Batch& batch, size_t paramOffset) {
|
||||||
resetStages();
|
resetStages();
|
||||||
|
@ -385,8 +405,11 @@ void GLBackend::do_popProfileRange(const Batch& batch, size_t paramOffset) {
|
||||||
// term strategy is to get rid of any GL calls in favor of the HIFI GPU API
|
// term strategy is to get rid of any GL calls in favor of the HIFI GPU API
|
||||||
|
|
||||||
// As long as we don;t use several versions of shaders we can avoid this more complex code path
|
// As long as we don;t use several versions of shaders we can avoid this more complex code path
|
||||||
// #define GET_UNIFORM_LOCATION(shaderUniformLoc) _pipeline._programShader->getUniformLocation(shaderUniformLoc, isStereo());
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
#define GET_UNIFORM_LOCATION(shaderUniformLoc) _pipeline._programShader->getUniformLocation(shaderUniformLoc, (GLShader::Version) isStereo())
|
||||||
|
#else
|
||||||
#define GET_UNIFORM_LOCATION(shaderUniformLoc) shaderUniformLoc
|
#define GET_UNIFORM_LOCATION(shaderUniformLoc) shaderUniformLoc
|
||||||
|
#endif
|
||||||
|
|
||||||
void GLBackend::do_glUniform1i(const Batch& batch, size_t paramOffset) {
|
void GLBackend::do_glUniform1i(const Batch& batch, size_t paramOffset) {
|
||||||
if (_pipeline._program == 0) {
|
if (_pipeline._program == 0) {
|
||||||
|
|
|
@ -29,6 +29,29 @@
|
||||||
|
|
||||||
#include "GLShared.h"
|
#include "GLShared.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Different versions for the stereo drawcall
|
||||||
|
// Current preferred is "instanced" which draw the shape twice but instanced and rely on clipping plane to draw left/right side only
|
||||||
|
//#define GPU_STEREO_TECHNIQUE_DOUBLED_SIMPLE
|
||||||
|
//#define GPU_STEREO_TECHNIQUE_DOUBLED_SMARTER
|
||||||
|
#define GPU_STEREO_TECHNIQUE_INSTANCED
|
||||||
|
|
||||||
|
|
||||||
|
// Let these be configured by the one define picked above
|
||||||
|
#ifdef GPU_STEREO_TECHNIQUE_DOUBLED_SIMPLE
|
||||||
|
#define GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_TECHNIQUE_DOUBLED_SMARTER
|
||||||
|
#define GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
|
#define GPU_STEREO_CAMERA_BUFFER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_TECHNIQUE_INSTANCED
|
||||||
|
#define GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
#define GPU_STEREO_CAMERA_BUFFER
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace gpu { namespace gl {
|
namespace gpu { namespace gl {
|
||||||
|
|
||||||
class GLBackend : public Backend, public std::enable_shared_from_this<GLBackend> {
|
class GLBackend : public Backend, public std::enable_shared_from_this<GLBackend> {
|
||||||
|
@ -204,7 +227,10 @@ protected:
|
||||||
|
|
||||||
void renderPassTransfer(const Batch& batch);
|
void renderPassTransfer(const Batch& batch);
|
||||||
void renderPassDraw(const Batch& batch);
|
void renderPassDraw(const Batch& batch);
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
void setupStereoSide(int side);
|
void setupStereoSide(int side);
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void initInput() final;
|
virtual void initInput() final;
|
||||||
virtual void killInput() final;
|
virtual void killInput() final;
|
||||||
|
@ -262,7 +288,19 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TransformStageState {
|
struct TransformStageState {
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
struct Cameras {
|
||||||
|
TransformCamera _cams[2];
|
||||||
|
|
||||||
|
Cameras() {};
|
||||||
|
Cameras(const TransformCamera& cam) { memcpy(_cams, &cam, sizeof(TransformCamera)); };
|
||||||
|
Cameras(const TransformCamera& camL, const TransformCamera& camR) { memcpy(_cams, &camL, sizeof(TransformCamera)); memcpy(_cams + 1, &camR, sizeof(TransformCamera)); };
|
||||||
|
};
|
||||||
|
|
||||||
|
using CameraBufferElement = Cameras;
|
||||||
|
#else
|
||||||
using CameraBufferElement = TransformCamera;
|
using CameraBufferElement = TransformCamera;
|
||||||
|
#endif
|
||||||
using TransformCameras = std::vector<CameraBufferElement>;
|
using TransformCameras = std::vector<CameraBufferElement>;
|
||||||
|
|
||||||
TransformCamera _camera;
|
TransformCamera _camera;
|
||||||
|
|
|
@ -187,7 +187,11 @@ void GLBackend::updateInput() {
|
||||||
glVertexAttribFormat(slot + locNum, count, type, isNormalized, offset + locNum * perLocationSize);
|
glVertexAttribFormat(slot + locNum, count, type, isNormalized, offset + locNum * perLocationSize);
|
||||||
glVertexAttribBinding(slot + locNum, attrib._channel);
|
glVertexAttribBinding(slot + locNum, attrib._channel);
|
||||||
}
|
}
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glVertexBindingDivisor(attrib._channel, attrib._frequency * (isStereo() ? 2 : 1));
|
||||||
|
#else
|
||||||
glVertexBindingDivisor(attrib._channel, attrib._frequency);
|
glVertexBindingDivisor(attrib._channel, attrib._frequency);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
@ -306,7 +310,11 @@ void GLBackend::updateInput() {
|
||||||
for (size_t locNum = 0; locNum < locationCount; ++locNum) {
|
for (size_t locNum = 0; locNum < locationCount; ++locNum) {
|
||||||
glVertexAttribPointer(slot + (GLuint)locNum, count, type, isNormalized, stride,
|
glVertexAttribPointer(slot + (GLuint)locNum, count, type, isNormalized, stride,
|
||||||
reinterpret_cast<GLvoid*>(pointer + perLocationStride * (GLuint)locNum));
|
reinterpret_cast<GLvoid*>(pointer + perLocationStride * (GLuint)locNum));
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereo() ? 2 : 1));
|
||||||
|
#else
|
||||||
glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency);
|
glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Support properly the IAttrib version
|
// TODO: Support properly the IAttrib version
|
||||||
|
|
|
@ -48,7 +48,13 @@ void GLBackend::do_setPipeline(const Batch& batch, size_t paramOffset) {
|
||||||
|
|
||||||
// check the program cache
|
// check the program cache
|
||||||
// pick the program version
|
// pick the program version
|
||||||
|
// check the program cache
|
||||||
|
// pick the program version
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
GLuint glprogram = pipelineObject->_program->getProgram((GLShader::Version) isStereo());
|
||||||
|
#else
|
||||||
GLuint glprogram = pipelineObject->_program->getProgram();
|
GLuint glprogram = pipelineObject->_program->getProgram();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_pipeline._program != glprogram) {
|
if (_pipeline._program != glprogram) {
|
||||||
_pipeline._program = glprogram;
|
_pipeline._program = glprogram;
|
||||||
|
|
|
@ -31,10 +31,25 @@ void GLBackend::do_setProjectionTransform(const Batch& batch, size_t paramOffset
|
||||||
void GLBackend::do_setViewportTransform(const Batch& batch, size_t paramOffset) {
|
void GLBackend::do_setViewportTransform(const Batch& batch, size_t paramOffset) {
|
||||||
memcpy(&_transform._viewport, batch.readData(batch._params[paramOffset]._uint), sizeof(Vec4i));
|
memcpy(&_transform._viewport, batch.readData(batch._params[paramOffset]._uint), sizeof(Vec4i));
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
{
|
||||||
|
ivec4& vp = _transform._viewport;
|
||||||
|
glViewport(vp.x, vp.y, vp.z, vp.w);
|
||||||
|
|
||||||
|
// Where we assign the GL viewport
|
||||||
|
if (_stereo._enable) {
|
||||||
|
vp.z /= 2;
|
||||||
|
if (_stereo._pass) {
|
||||||
|
vp.x += vp.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!_inRenderTransferPass && !isStereo()) {
|
if (!_inRenderTransferPass && !isStereo()) {
|
||||||
ivec4& vp = _transform._viewport;
|
ivec4& vp = _transform._viewport;
|
||||||
glViewport(vp.x, vp.y, vp.z, vp.w);
|
glViewport(vp.x, vp.y, vp.z, vp.w);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
|
// The Viewport is tagged invalid because the CameraTransformUBO is not up to date and will need update on next drawcall
|
||||||
_transform._invalidViewport = true;
|
_transform._invalidViewport = true;
|
||||||
|
@ -100,13 +115,21 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo
|
||||||
if (_invalidView || _invalidProj || _invalidViewport) {
|
if (_invalidView || _invalidProj || _invalidViewport) {
|
||||||
size_t offset = _cameraUboSize * _cameras.size();
|
size_t offset = _cameraUboSize * _cameras.size();
|
||||||
_cameraOffsets.push_back(TransformStageState::Pair(commandIndex, offset));
|
_cameraOffsets.push_back(TransformStageState::Pair(commandIndex, offset));
|
||||||
|
|
||||||
if (stereo._enable) {
|
if (stereo._enable) {
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
_cameras.push_back(CameraBufferElement(_camera.getEyeCamera(0, stereo, _view), _camera.getEyeCamera(1, stereo, _view)));
|
||||||
|
#else
|
||||||
_cameras.push_back((_camera.getEyeCamera(0, stereo, _view)));
|
_cameras.push_back((_camera.getEyeCamera(0, stereo, _view)));
|
||||||
_cameras.push_back((_camera.getEyeCamera(1, stereo, _view)));
|
_cameras.push_back((_camera.getEyeCamera(1, stereo, _view)));
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
_cameras.push_back(CameraBufferElement(_camera.recomputeDerived(_view)));
|
||||||
|
#else
|
||||||
_cameras.push_back((_camera.recomputeDerived(_view)));
|
_cameras.push_back((_camera.recomputeDerived(_view)));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags are clean
|
// Flags are clean
|
||||||
|
@ -122,9 +145,13 @@ void GLBackend::TransformStageState::update(size_t commandIndex, const StereoSta
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != INVALID_OFFSET) {
|
if (offset != INVALID_OFFSET) {
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
bindCurrentCamera(0);
|
||||||
|
#else
|
||||||
if (!stereo._enable) {
|
if (!stereo._enable) {
|
||||||
bindCurrentCamera(0);
|
bindCurrentCamera(0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +175,11 @@ void GLBackend::updateTransform(const Batch& batch) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _transform._drawCallInfoBuffer);
|
glBindBuffer(GL_ARRAY_BUFFER, _transform._drawCallInfoBuffer);
|
||||||
glVertexAttribIPointer(gpu::Stream::DRAW_CALL_INFO, 2, GL_UNSIGNED_SHORT, 0,
|
glVertexAttribIPointer(gpu::Stream::DRAW_CALL_INFO, 2, GL_UNSIGNED_SHORT, 0,
|
||||||
_transform._drawCallInfoOffsets[batch._currentNamedCall]);
|
_transform._drawCallInfoOffsets[batch._currentNamedCall]);
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glVertexAttribDivisor(gpu::Stream::DRAW_CALL_INFO, (isStereo() ? 2 : 1));
|
||||||
|
#else
|
||||||
glVertexAttribDivisor(gpu::Stream::DRAW_CALL_INFO, 1);
|
glVertexAttribDivisor(gpu::Stream::DRAW_CALL_INFO, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
|
|
|
@ -54,9 +54,24 @@ static const std::array<std::string, NUM_SHADER_DOMAINS> DOMAIN_DEFINES { {
|
||||||
"#define GPU_GEOMETRY_SHADER",
|
"#define GPU_GEOMETRY_SHADER",
|
||||||
} };
|
} };
|
||||||
|
|
||||||
|
// Stereo specific defines
|
||||||
|
static const std::string stereoVersion {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
"#define GPU_TRANSFORM_IS_STEREO\n#define GPU_TRANSFORM_STEREO_CAMERA\n#define GPU_TRANSFORM_STEREO_CAMERA_INSTANCED\n#define GPU_TRANSFORM_STEREO_SPLIT_SCREEN"
|
||||||
|
#endif
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_DOUBLED
|
||||||
|
#ifdef GPU_STEREO_CAMERA_BUFFER
|
||||||
|
"#define GPU_TRANSFORM_IS_STEREO\n#define GPU_TRANSFORM_STEREO_CAMERA\n#define GPU_TRANSFORM_STEREO_CAMERA_ATTRIBUTED"
|
||||||
|
#else
|
||||||
|
"#define GPU_TRANSFORM_IS_STEREO"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
// Versions specific of the shader
|
// Versions specific of the shader
|
||||||
static const std::array<std::string, GLShader::NumVersions> VERSION_DEFINES { {
|
static const std::array<std::string, GLShader::NumVersions> VERSION_DEFINES { {
|
||||||
""
|
"",
|
||||||
|
stereoVersion
|
||||||
} };
|
} };
|
||||||
|
|
||||||
GLShader* compileBackendShader(GLBackend& backend, const Shader& shader) {
|
GLShader* compileBackendShader(GLBackend& backend, const Shader& shader) {
|
||||||
|
@ -181,7 +196,8 @@ bool GLShader::makeProgram(GLBackend& backend, Shader& shader, const Shader::Bin
|
||||||
// Define the public slots only from the default version
|
// Define the public slots only from the default version
|
||||||
if (version == 0) {
|
if (version == 0) {
|
||||||
shader.defineSlots(uniforms, buffers, textures, samplers, inputs, outputs);
|
shader.defineSlots(uniforms, buffers, textures, samplers, inputs, outputs);
|
||||||
} else {
|
} // else
|
||||||
|
{
|
||||||
GLShader::UniformMapping mapping;
|
GLShader::UniformMapping mapping;
|
||||||
for (auto srcUniform : shader.getUniforms()) {
|
for (auto srcUniform : shader.getUniforms()) {
|
||||||
mapping[srcUniform._location] = uniforms.findLocation(srcUniform._name);
|
mapping[srcUniform._location] = uniforms.findLocation(srcUniform._name);
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
|
|
||||||
enum Version {
|
enum Version {
|
||||||
Mono = 0,
|
Mono = 0,
|
||||||
|
Stereo,
|
||||||
|
|
||||||
NumVersions
|
NumVersions
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,8 +42,8 @@ public:
|
||||||
|
|
||||||
GLint getUniformLocation(GLint srcLoc, Version version = Mono) {
|
GLint getUniformLocation(GLint srcLoc, Version version = Mono) {
|
||||||
// THIS will be used in the future PR as we grow the number of versions
|
// THIS will be used in the future PR as we grow the number of versions
|
||||||
// return _uniformMappings[version][srcLoc];
|
return _uniformMappings[version][srcLoc];
|
||||||
return srcLoc;
|
// return srcLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::weak_ptr<GLBackend> _backend;
|
const std::weak_ptr<GLBackend> _backend;
|
||||||
|
|
|
@ -25,11 +25,14 @@ void GL41Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
||||||
|
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, 2);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawArrays(mode, startVertex, numVertices);
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawArrays(mode, startVertex, numVertices);
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
#endif
|
||||||
_stats._DSNumTriangles += 2 * numVertices / 3;
|
_stats._DSNumTriangles += 2 * numVertices / 3;
|
||||||
_stats._DSNumDrawcalls += 2;
|
_stats._DSNumDrawcalls += 2;
|
||||||
|
|
||||||
|
@ -55,11 +58,14 @@ void GL41Backend::do_drawIndexed(const Batch& batch, size_t paramOffset) {
|
||||||
GLvoid* indexBufferByteOffset = reinterpret_cast<GLvoid*>(startIndex * typeByteSize + _input._indexBufferOffset);
|
GLvoid* indexBufferByteOffset = reinterpret_cast<GLvoid*>(startIndex * typeByteSize + _input._indexBufferOffset);
|
||||||
|
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawElementsInstanced(mode, numIndices, glType, indexBufferByteOffset, 2);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
||||||
|
#endif
|
||||||
_stats._DSNumTriangles += 2 * numIndices / 3;
|
_stats._DSNumTriangles += 2 * numIndices / 3;
|
||||||
_stats._DSNumDrawcalls += 2;
|
_stats._DSNumDrawcalls += 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,11 +89,14 @@ void GL41Backend::do_drawInstanced(const Batch& batch, size_t paramOffset) {
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
GLint trueNumInstances = 2 * numInstances;
|
GLint trueNumInstances = 2 * numInstances;
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, trueNumInstances);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawArraysInstancedARB(mode, startVertex, numVertices, numInstances);
|
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawArraysInstancedARB(mode, startVertex, numVertices, numInstances);
|
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
||||||
|
#endif
|
||||||
_stats._DSNumTriangles += (trueNumInstances * numVertices) / 3;
|
_stats._DSNumTriangles += (trueNumInstances * numVertices) / 3;
|
||||||
_stats._DSNumDrawcalls += trueNumInstances;
|
_stats._DSNumDrawcalls += trueNumInstances;
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,10 +133,14 @@ void GL41Backend::do_drawIndexedInstanced(const Batch& batch, size_t paramOffset
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
GLint trueNumInstances = 2 * numInstances;
|
GLint trueNumInstances = 2 * numInstances;
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glbackend_glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, trueNumInstances, 0, startInstance);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glbackend_glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
glbackend_glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glbackend_glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
glbackend_glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
||||||
|
#endif
|
||||||
|
|
||||||
_stats._DSNumTriangles += (trueNumInstances * numIndices) / 3;
|
_stats._DSNumTriangles += (trueNumInstances * numIndices) / 3;
|
||||||
_stats._DSNumDrawcalls += trueNumInstances;
|
_stats._DSNumDrawcalls += trueNumInstances;
|
||||||
|
|
|
@ -25,10 +25,14 @@ void GL45Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
uint32 startVertex = batch._params[paramOffset + 0]._uint;
|
||||||
|
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, 2);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawArrays(mode, startVertex, numVertices);
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawArrays(mode, startVertex, numVertices);
|
glDrawArrays(mode, startVertex, numVertices);
|
||||||
|
#endif
|
||||||
|
|
||||||
_stats._DSNumTriangles += 2 * numVertices / 3;
|
_stats._DSNumTriangles += 2 * numVertices / 3;
|
||||||
_stats._DSNumDrawcalls += 2;
|
_stats._DSNumDrawcalls += 2;
|
||||||
|
@ -55,11 +59,14 @@ void GL45Backend::do_drawIndexed(const Batch& batch, size_t paramOffset) {
|
||||||
GLvoid* indexBufferByteOffset = reinterpret_cast<GLvoid*>(startIndex * typeByteSize + _input._indexBufferOffset);
|
GLvoid* indexBufferByteOffset = reinterpret_cast<GLvoid*>(startIndex * typeByteSize + _input._indexBufferOffset);
|
||||||
|
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawElementsInstanced(mode, numIndices, glType, indexBufferByteOffset, 2);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
glDrawElements(mode, numIndices, glType, indexBufferByteOffset);
|
||||||
|
#endif
|
||||||
_stats._DSNumTriangles += 2 * numIndices / 3;
|
_stats._DSNumTriangles += 2 * numIndices / 3;
|
||||||
_stats._DSNumDrawcalls += 2;
|
_stats._DSNumDrawcalls += 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,10 +90,14 @@ void GL45Backend::do_drawInstanced(const Batch& batch, size_t paramOffset) {
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
GLint trueNumInstances = 2 * numInstances;
|
GLint trueNumInstances = 2 * numInstances;
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawArraysInstanced(mode, startVertex, numVertices, trueNumInstances);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
glDrawArraysInstanced(mode, startVertex, numVertices, numInstances);
|
||||||
|
#endif
|
||||||
|
|
||||||
_stats._DSNumTriangles += (trueNumInstances * numVertices) / 3;
|
_stats._DSNumTriangles += (trueNumInstances * numVertices) / 3;
|
||||||
_stats._DSNumDrawcalls += trueNumInstances;
|
_stats._DSNumDrawcalls += trueNumInstances;
|
||||||
|
@ -112,10 +123,15 @@ void GL45Backend::do_drawIndexedInstanced(const Batch& batch, size_t paramOffset
|
||||||
|
|
||||||
if (isStereo()) {
|
if (isStereo()) {
|
||||||
GLint trueNumInstances = 2 * numInstances;
|
GLint trueNumInstances = 2 * numInstances;
|
||||||
|
|
||||||
|
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
|
||||||
|
glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, trueNumInstances, 0, startInstance);
|
||||||
|
#else
|
||||||
setupStereoSide(0);
|
setupStereoSide(0);
|
||||||
glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
||||||
setupStereoSide(1);
|
setupStereoSide(1);
|
||||||
glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
glDrawElementsInstancedBaseVertexBaseInstance(mode, numIndices, glType, indexBufferByteOffset, numInstances, 0, startInstance);
|
||||||
|
#endif
|
||||||
_stats._DSNumTriangles += (trueNumInstances * numIndices) / 3;
|
_stats._DSNumTriangles += (trueNumInstances * numIndices) / 3;
|
||||||
_stats._DSNumDrawcalls += trueNumInstances;
|
_stats._DSNumDrawcalls += trueNumInstances;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,29 +22,84 @@ struct TransformCamera {
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(std140) uniform transformCameraBuffer {
|
layout(std140) uniform transformCameraBuffer {
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA
|
||||||
|
TransformCamera _camera[2];
|
||||||
|
#else
|
||||||
TransformCamera _camera;
|
TransformCamera _camera;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
TransformCamera _camera;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef GPU_VERTEX_SHADER
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA_ATTRIBUTED
|
||||||
|
layout(location=14) in int _inStereoSide;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
flat out int _stereoSide;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GPU_PIXEL_SHADER
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA
|
||||||
|
flat in int _stereoSide;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
TransformCamera getTransformCamera() {
|
TransformCamera getTransformCamera() {
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA
|
||||||
|
#ifdef GPU_VERTEX_SHADER
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA_ATTRIBUTED
|
||||||
|
_stereoSide = _inStereoSide;
|
||||||
|
#endif
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA_INSTANCED
|
||||||
|
_stereoSide = gl_InstanceID % 2;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return _camera[_stereoSide];
|
||||||
|
#else
|
||||||
return _camera;
|
return _camera;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return _camera;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 getEyeWorldPos() {
|
vec3 getEyeWorldPos() {
|
||||||
return _camera._viewInverse[3].xyz;
|
return getTransformCamera()._viewInverse[3].xyz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cam_isStereo() {
|
bool cam_isStereo() {
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
return getTransformCamera()._stereoInfo.x > 0.0;
|
||||||
|
#else
|
||||||
return _camera._stereoInfo.x > 0.0;
|
return _camera._stereoInfo.x > 0.0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float cam_getStereoSide() {
|
float cam_getStereoSide() {
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_CAMERA
|
||||||
|
return getTransformCamera()._stereoInfo.y;
|
||||||
|
#else
|
||||||
return _camera._stereoInfo.y;
|
return _camera._stereoInfo.y;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return _camera._stereoInfo.y;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
||||||
<@func declareStandardObjectTransform()@>
|
<@func declareStandardObjectTransform()@>
|
||||||
struct TransformObject {
|
struct TransformObject {
|
||||||
mat4 _model;
|
mat4 _model;
|
||||||
|
@ -92,6 +147,25 @@ TransformObject getTransformObject() {
|
||||||
<$viewport$> = <$cameraTransform$>._viewport;
|
<$viewport$> = <$cameraTransform$>._viewport;
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
<@func transformStereoClipsSpace(cameraTransform, clipPos)@>
|
||||||
|
{
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
vec4 eyeClipEdge[2]= vec4[2](vec4(-1,0,0,1), vec4(1,0,0,1));
|
||||||
|
vec2 eyeOffsetScale = vec2(-0.5, +0.5);
|
||||||
|
uint eyeIndex = _stereoSide;
|
||||||
|
gl_ClipDistance[0] = dot(<$clipPos$>, eyeClipEdge[eyeIndex]);
|
||||||
|
float newClipPosX = <$clipPos$>.x * 0.5 + eyeOffsetScale[eyeIndex] * <$clipPos$>.w;
|
||||||
|
<$clipPos$>.x = newClipPosX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
||||||
<@func transformModelToEyeWorldAlignedPos(cameraTransform, objectTransform, modelPos, eyeWorldAlignedPos)@>
|
<@func transformModelToEyeWorldAlignedPos(cameraTransform, objectTransform, modelPos, eyeWorldAlignedPos)@>
|
||||||
<!// Bring the model pos in the world aligned space centered on the eye axis !>
|
<!// Bring the model pos in the world aligned space centered on the eye axis !>
|
||||||
{ // _transformModelToEyeWorldAlignedPos
|
{ // _transformModelToEyeWorldAlignedPos
|
||||||
|
@ -108,6 +182,8 @@ TransformObject getTransformObject() {
|
||||||
<$transformModelToEyeWorldAlignedPos($cameraTransform$, $objectTransform$, $modelPos$, eyeWAPos)$>
|
<$transformModelToEyeWorldAlignedPos($cameraTransform$, $objectTransform$, $modelPos$, eyeWAPos)$>
|
||||||
|
|
||||||
<$clipPos$> = <$cameraTransform$>._projectionViewUntranslated * eyeWAPos;
|
<$clipPos$> = <$cameraTransform$>._projectionViewUntranslated * eyeWAPos;
|
||||||
|
|
||||||
|
<$transformStereoClipsSpace($cameraTransform$, $clipPos$)$>
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -117,6 +193,8 @@ TransformObject getTransformObject() {
|
||||||
<$transformModelToEyeWorldAlignedPos($cameraTransform$, $objectTransform$, $modelPos$, eyeWAPos)$>
|
<$transformModelToEyeWorldAlignedPos($cameraTransform$, $objectTransform$, $modelPos$, eyeWAPos)$>
|
||||||
<$clipPos$> = <$cameraTransform$>._projectionViewUntranslated * eyeWAPos;
|
<$clipPos$> = <$cameraTransform$>._projectionViewUntranslated * eyeWAPos;
|
||||||
<$eyePos$> = vec4((<$cameraTransform$>._view * vec4(eyeWAPos.xyz, 0.0)).xyz, 1.0);
|
<$eyePos$> = vec4((<$cameraTransform$>._view * vec4(eyeWAPos.xyz, 0.0)).xyz, 1.0);
|
||||||
|
|
||||||
|
<$transformStereoClipsSpace($cameraTransform$, $clipPos$)$>
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -139,7 +217,6 @@ TransformObject getTransformObject() {
|
||||||
vec3 mr0 = <$objectTransform$>._modelInverse[0].xyz;
|
vec3 mr0 = <$objectTransform$>._modelInverse[0].xyz;
|
||||||
vec3 mr1 = <$objectTransform$>._modelInverse[1].xyz;
|
vec3 mr1 = <$objectTransform$>._modelInverse[1].xyz;
|
||||||
vec3 mr2 = <$objectTransform$>._modelInverse[2].xyz;
|
vec3 mr2 = <$objectTransform$>._modelInverse[2].xyz;
|
||||||
|
|
||||||
<$worldDir$> = vec3(dot(mr0, <$modelDir$>), dot(mr1, <$modelDir$>), dot(mr2, <$modelDir$>));
|
<$worldDir$> = vec3(dot(mr0, <$modelDir$>), dot(mr1, <$modelDir$>), dot(mr2, <$modelDir$>));
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
@ -173,6 +250,8 @@ TransformObject getTransformObject() {
|
||||||
<@func transformEyeToClipPos(cameraTransform, eyePos, clipPos)@>
|
<@func transformEyeToClipPos(cameraTransform, eyePos, clipPos)@>
|
||||||
{ // transformEyeToClipPos
|
{ // transformEyeToClipPos
|
||||||
<$clipPos$> = <$cameraTransform$>._projection * vec4(<$eyePos$>.xyz, 1.0);
|
<$clipPos$> = <$cameraTransform$>._projection * vec4(<$eyePos$>.xyz, 1.0);
|
||||||
|
|
||||||
|
<$transformStereoClipsSpace($cameraTransform$, $clipPos$)$>
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,6 @@ void main(void) {
|
||||||
|
|
||||||
// Position is supposed to come in clip space
|
// Position is supposed to come in clip space
|
||||||
gl_Position = vec4(inPosition.xy, 0.0, 1.0);
|
gl_Position = vec4(inPosition.xy, 0.0, 1.0);
|
||||||
|
|
||||||
|
<$transformStereoClipsSpace(cam, gl_Position)$>
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,14 @@ void main(void) {
|
||||||
vec4 projected = gl_Position / gl_Position.w;
|
vec4 projected = gl_Position / gl_Position.w;
|
||||||
projected.xy = (projected.xy + 1.0) * 0.5;
|
projected.xy = (projected.xy + 1.0) * 0.5;
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
#else
|
||||||
if (cam_isStereo()) {
|
if (cam_isStereo()) {
|
||||||
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
||||||
} else {
|
} else {
|
||||||
const float depth = -1.0; //Draw at near plane
|
const float depth = -1.0; //Draw at near plane
|
||||||
|
@ -47,11 +52,27 @@ void main(void) {
|
||||||
);
|
);
|
||||||
vec4 pos = UNIT_QUAD[gl_VertexID];
|
vec4 pos = UNIT_QUAD[gl_VertexID];
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
<$transformStereoClipsSpace(cam, pos)$>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
_texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0);
|
_texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0);
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
#else
|
||||||
if (cam_isStereo()) {
|
if (cam_isStereo()) {
|
||||||
_texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide());
|
_texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,14 @@ void main(void) {
|
||||||
vec4 projected = gl_Position / gl_Position.w;
|
vec4 projected = gl_Position / gl_Position.w;
|
||||||
projected.xy = (projected.xy + 1.0) * 0.5;
|
projected.xy = (projected.xy + 1.0) * 0.5;
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
#else
|
||||||
if (cam_isStereo()) {
|
if (cam_isStereo()) {
|
||||||
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
||||||
} else {
|
} else {
|
||||||
const float depth = -1.0; //Draw at near plane
|
const float depth = -1.0; //Draw at near plane
|
||||||
|
@ -60,10 +65,24 @@ void main(void) {
|
||||||
);
|
);
|
||||||
vec4 pos = UNIT_QUAD[gl_VertexID];
|
vec4 pos = UNIT_QUAD[gl_VertexID];
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
TransformCamera cam = getTransformCamera();
|
||||||
|
<$transformStereoClipsSpace(cam, pos)$>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
_texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0);
|
_texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0);
|
||||||
|
|
||||||
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||||
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||||
|
#else
|
||||||
if (cam_isStereo()) {
|
if (cam_isStereo()) {
|
||||||
_texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide());
|
_texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,9 +401,13 @@ bool OpenVrDisplayPlugin::internalActivate() {
|
||||||
memset(&timing, 0, sizeof(timing));
|
memset(&timing, 0, sizeof(timing));
|
||||||
timing.m_nSize = sizeof(vr::Compositor_FrameTiming);
|
timing.m_nSize = sizeof(vr::Compositor_FrameTiming);
|
||||||
vr::VRCompositor()->GetFrameTiming(&timing);
|
vr::VRCompositor()->GetFrameTiming(&timing);
|
||||||
_asyncReprojectionActive = timing.m_nReprojectionFlags & VRCompositor_ReprojectionAsync;
|
auto usingOpenVRForOculus = oculusViaOpenVR();
|
||||||
|
_asyncReprojectionActive = (timing.m_nReprojectionFlags & VRCompositor_ReprojectionAsync) || usingOpenVRForOculus;
|
||||||
|
|
||||||
_threadedSubmit = !_asyncReprojectionActive;
|
_threadedSubmit = !_asyncReprojectionActive;
|
||||||
|
if (usingOpenVRForOculus) {
|
||||||
|
qDebug() << "Oculus active via OpenVR: " << usingOpenVRForOculus;
|
||||||
|
}
|
||||||
qDebug() << "OpenVR Async Reprojection active: " << _asyncReprojectionActive;
|
qDebug() << "OpenVR Async Reprojection active: " << _asyncReprojectionActive;
|
||||||
qDebug() << "OpenVR Threaded submit enabled: " << _threadedSubmit;
|
qDebug() << "OpenVR Threaded submit enabled: " << _threadedSubmit;
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,12 @@ bool isOculusPresent() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool oculusViaOpenVR() {
|
||||||
|
static const QString DEBUG_FLAG("HIFI_DEBUG_OPENVR");
|
||||||
|
static bool enableDebugOpenVR = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
||||||
|
return enableDebugOpenVR && isOculusPresent() && vr::VR_IsHmdPresent();
|
||||||
|
}
|
||||||
|
|
||||||
bool openVrSupported() {
|
bool openVrSupported() {
|
||||||
static const QString DEBUG_FLAG("HIFI_DEBUG_OPENVR");
|
static const QString DEBUG_FLAG("HIFI_DEBUG_OPENVR");
|
||||||
static bool enableDebugOpenVR = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
static bool enableDebugOpenVR = QProcessEnvironment::systemEnvironment().contains(DEBUG_FLAG);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <controllers/Forward.h>
|
#include <controllers/Forward.h>
|
||||||
#include <plugins/Forward.h>
|
#include <plugins/Forward.h>
|
||||||
|
|
||||||
|
bool oculusViaOpenVR(); // is the user using Oculus via OpenVR
|
||||||
bool openVrSupported();
|
bool openVrSupported();
|
||||||
|
|
||||||
vr::IVRSystem* acquireOpenVrSystem();
|
vr::IVRSystem* acquireOpenVrSystem();
|
||||||
|
|
Loading…
Reference in a new issue