mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-10 13:47:23 +02:00
Merge branch 'gpu-error-tweak' into overlay
This commit is contained in:
commit
d9452cfd2e
8 changed files with 76 additions and 35 deletions
|
@ -12,6 +12,8 @@
|
|||
#include "GLBackendShared.h"
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
||||
{
|
||||
(&::gpu::GLBackend::do_draw),
|
||||
|
@ -141,6 +143,14 @@ bool GLBackend::checkGLError(const char* name) {
|
|||
}
|
||||
}
|
||||
|
||||
bool GLBackend::checkGLErrorDebug(const char* name) {
|
||||
#ifdef DEBUG
|
||||
checkGLError(name);
|
||||
#else
|
||||
Q_UNUSED(name);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLBackend::syncCache() {
|
||||
syncTransformStateCache();
|
||||
|
|
|
@ -49,6 +49,9 @@ public:
|
|||
|
||||
static bool checkGLError(const char* name = nullptr);
|
||||
|
||||
// Only checks in debug builds
|
||||
static bool checkGLErrorDebug(const char* name = nullptr);
|
||||
|
||||
static bool makeProgram(Shader& shader, const Shader::BindingSet& bindings = Shader::BindingSet());
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "GPULogging.h"
|
||||
#include "GLBackendShared.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
GLBackend::GLFramebuffer::GLFramebuffer() {}
|
||||
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
|
||||
#include "Batch.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
static const GLenum _primitiveToGLmode[NUM_PRIMITIVES] = {
|
||||
static const GLenum _primitiveToGLmode[gpu::NUM_PRIMITIVES] = {
|
||||
GL_POINTS,
|
||||
GL_LINES,
|
||||
GL_LINE_STRIP,
|
||||
|
@ -30,7 +28,7 @@ static const GLenum _primitiveToGLmode[NUM_PRIMITIVES] = {
|
|||
GL_QUAD_STRIP,
|
||||
};
|
||||
|
||||
static const GLenum _elementTypeToGLType[NUM_TYPES]= {
|
||||
static const GLenum _elementTypeToGLType[gpu::NUM_TYPES] = {
|
||||
GL_FLOAT,
|
||||
GL_INT,
|
||||
GL_UNSIGNED_INT,
|
||||
|
@ -49,10 +47,8 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= {
|
|||
GL_UNSIGNED_BYTE
|
||||
};
|
||||
|
||||
#if _DEBUG
|
||||
#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError(__FUNCTION__)
|
||||
#else
|
||||
#define CHECK_GL_ERROR() false
|
||||
#endif
|
||||
// Stupid preprocessor trick to turn the line macro into a string
|
||||
#define CHECK_GL_ERROR_HELPER(x) #x
|
||||
#define CHECK_GL_ERROR() gpu::GLBackend::checkGLErrorDebug(__FUNCTION__ ":" CHECK_GL_ERROR_HELPER(__LINE__))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "GPULogging.h"
|
||||
#include "GLBackendShared.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
GLBackend::GLTexture::GLTexture() :
|
||||
_storageStamp(0),
|
||||
|
|
|
@ -384,10 +384,12 @@ bool OctreePacketData::appendValue(const glm::vec3& value) {
|
|||
bool OctreePacketData::appendValue(const QVector<glm::vec3>& value) {
|
||||
uint16_t qVecSize = value.size();
|
||||
bool success = appendValue(qVecSize);
|
||||
success = append((const unsigned char*)value.constData(), qVecSize * sizeof(glm::vec3));
|
||||
if (success) {
|
||||
_bytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||
_totalBytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||
success = append((const unsigned char*)value.constData(), qVecSize * sizeof(glm::vec3));
|
||||
if (success) {
|
||||
_bytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||
_totalBytesOfValues += qVecSize * sizeof(glm::vec3);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -13,35 +13,61 @@
|
|||
#include "SharedLogging.h"
|
||||
#include "VariantMapToScriptValue.h"
|
||||
|
||||
|
||||
QScriptValue variantToScriptValue(QVariant& qValue, QScriptEngine& scriptEngine) {
|
||||
switch(qValue.type()) {
|
||||
case QVariant::Bool:
|
||||
return qValue.toBool();
|
||||
break;
|
||||
case QVariant::Int:
|
||||
return qValue.toInt();
|
||||
break;
|
||||
case QVariant::Double:
|
||||
return qValue.toDouble();
|
||||
break;
|
||||
case QVariant::String: {
|
||||
return scriptEngine.newVariant(qValue);
|
||||
break;
|
||||
}
|
||||
case QVariant::Map: {
|
||||
QVariantMap childMap = qValue.toMap();
|
||||
return variantMapToScriptValue(childMap, scriptEngine);
|
||||
break;
|
||||
}
|
||||
case QVariant::List: {
|
||||
QVariantList childList = qValue.toList();
|
||||
return variantListToScriptValue(childList, scriptEngine);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qCDebug(shared) << "unhandled QScript type" << qValue.type();
|
||||
break;
|
||||
}
|
||||
|
||||
return QScriptValue();
|
||||
}
|
||||
|
||||
|
||||
QScriptValue variantMapToScriptValue(QVariantMap& variantMap, QScriptEngine& scriptEngine) {
|
||||
QScriptValue scriptValue = scriptEngine.newObject();
|
||||
|
||||
for (QVariantMap::const_iterator iter = variantMap.begin(); iter != variantMap.end(); ++iter) {
|
||||
QString key = iter.key();
|
||||
QVariant qValue = iter.value();
|
||||
|
||||
switch(qValue.type()) {
|
||||
case QVariant::Bool:
|
||||
scriptValue.setProperty(key, qValue.toBool());
|
||||
break;
|
||||
case QVariant::Int:
|
||||
scriptValue.setProperty(key, qValue.toInt());
|
||||
break;
|
||||
case QVariant::Double:
|
||||
scriptValue.setProperty(key, qValue.toDouble());
|
||||
break;
|
||||
case QVariant::String: {
|
||||
scriptValue.setProperty(key, scriptEngine.newVariant(qValue));
|
||||
break;
|
||||
}
|
||||
case QVariant::Map: {
|
||||
QVariantMap childMap = qValue.toMap();
|
||||
scriptValue.setProperty(key, variantMapToScriptValue(childMap, scriptEngine));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qCDebug(shared) << "unhandled QScript type" << qValue.type();
|
||||
}
|
||||
scriptValue.setProperty(key, variantToScriptValue(qValue, scriptEngine));
|
||||
}
|
||||
|
||||
return scriptValue;
|
||||
}
|
||||
|
||||
|
||||
QScriptValue variantListToScriptValue(QVariantList& variantList, QScriptEngine& scriptEngine) {
|
||||
QScriptValue scriptValue = scriptEngine.newObject();
|
||||
|
||||
scriptValue.setProperty("length", variantList.size());
|
||||
int i = 0;
|
||||
foreach (QVariant v, variantList) {
|
||||
scriptValue.setProperty(i++, variantToScriptValue(v, scriptEngine));
|
||||
}
|
||||
|
||||
return scriptValue;
|
||||
|
|
|
@ -13,4 +13,6 @@
|
|||
#include <QScriptValue>
|
||||
#include <QScriptEngine>
|
||||
|
||||
QScriptValue variantToScriptValue(QVariant& qValue, QScriptEngine& scriptEngine);
|
||||
QScriptValue variantMapToScriptValue(QVariantMap& variantMap, QScriptEngine& scriptEngine);
|
||||
QScriptValue variantListToScriptValue(QVariantList& variantList, QScriptEngine& scriptEngine);
|
||||
|
|
Loading…
Reference in a new issue