void CMenuPlot::EnableDelete(bool b) { if(!m_bPreview) { Enable(_ID(IDmenuPlotRemove),b); Enable(_ID(IDmenuPlotRemoveOthers),b); } }
void PostAAPreRenderOperator::idle(const Configuration& config) { I32 samples = config.rendering.postFX.postAASamples; if (_postAASamples != samples) { _postAASamples = samples; _fxaaConstants.set("dvd_qualityMultiplier", GFX::PushConstantType::INT, _postAASamples); } if (_idleCount == 0) { _useSMAA = _ID(config.rendering.postFX.postAAType.c_str()) == _ID("SMAA"); } _idleCount = (++_idleCount % 60); }
void SceneRenderState::enableOption(RenderOptions option) { if (Config::Build::IS_DEBUG_BUILD) { DIVIDE_ASSERT(option != RenderOptions::PLAY_ANIMATIONS, "SceneRenderState::enableOption error: can't update animation state directly!"); if (option == RenderOptions::RENDER_SKELETONS) { Console::d_printfn(Locale::get(_ID("TOGGLE_SCENE_SKELETONS")), "On"); } else if (option == RenderOptions::RENDER_AABB) { Console::d_printfn(Locale::get(_ID("TOGGLE_SCENE_BOUNDING_BOXES")), "On"); } } SetBit(_stateMask, to_U32(option)); }
void CMenuPlot::SetSync(bool b) { if(!m_bPreview) { Check(_ID(IDmenuPlotSync),b); } }
IMPrimitive* GFXDevice::newIMP() const { bool locked = _gpuObjectArenaMutex.try_lock(); IMPrimitive* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new IM emulation primitive. The callee is responsible /// for it's deletion! temp = new (_gpuObjectArena) glIMPrimitive(refThis(this)); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkIMPrimitive(refThis(this)); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noIMPrimitive(refThis(this)); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
ShaderBuffer* GFXDevice::newSB(const ShaderBufferDescriptor& descriptor) const { bool locked = _gpuObjectArenaMutex.try_lock(); ShaderBuffer* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new shader buffer. The callee is responsible for it's deletion! /// The OpenGL implementation creates either an 'Uniform Buffer Object' if unbound is false /// or a 'Shader Storage Block Object' otherwise /// The shader buffer can also be persistently mapped, if requested temp = new (_gpuObjectArena) glUniformBuffer(refThis(this), descriptor); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkUniformBuffer(refThis(this), descriptor); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noUniformBuffer(refThis(this), descriptor); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
RenderTarget* GFXDevice::newRT(const RenderTargetDescriptor& descriptor) const { bool locked = _gpuObjectArenaMutex.try_lock(); RenderTarget* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new framebuffer. /// The callee is responsible for it's deletion! temp = new (_gpuObjectArena) glFramebuffer(refThis(this), nullptr, descriptor); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkRenderTarget(refThis(this), descriptor); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noRenderTarget(refThis(this), descriptor); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
GenericVertexData* GFXDevice::newGVD(const U32 ringBufferLength, const char* name) const { bool locked = _gpuObjectArenaMutex.try_lock(); GenericVertexData* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new generic vertex data object /// The callee is responsible for it's deletion! temp = new (_gpuObjectArena) glGenericVertexData(refThis(this), ringBufferLength, name); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkGenericVertexData(refThis(this), ringBufferLength, name); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noGenericVertexData(refThis(this), ringBufferLength, name); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
PixelBuffer* GFXDevice::newPB(PBType type, const char* name) const { bool locked = _gpuObjectArenaMutex.try_lock(); PixelBuffer* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new pixel buffer using the requested format. /// The callee is responsible for it's deletion! temp = new (_gpuObjectArena) glPixelBuffer(refThis(this), type, name); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkPixelBuffer(refThis(this), type, name); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noPixelBuffer(refThis(this), type, name); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
void CMenuPlot::EnableAppend(bool b) { if(!m_bPreview) { Enable(_ID(IDmenuPlotAppend),b); } }
void LocalClient::HandleDisconnectOpCode(WorldPacket& p) { U8 code; p >> code; Console::printfn(Locale::get(_ID("ASIO_CLOSE"))); if (code == 0) close(); // else handleError(code); }
void ApplicationTimer::update() { const TimeValue currentTicks = getCurrentTicksInternal(); _elapsedTimeUs = getElapsedTimeInternal(currentTicks); const USec duration = std::chrono::duration_cast<USec>(currentTicks - _frameDelay); _speedfactor = Time::MicrosecondsToSeconds<F32>(static_cast<U64>(duration.count() * _targetFrameRate)); _frameDelay = currentTicks; const U64 elapsedTime = getElapsedTimeInternal(currentTicks); _frameRateHandler.tick(elapsedTime); if (Config::Profile::BENCHMARK_PERFORMANCE) { if (elapsedTime - _lastBenchmarkTimeStamp > Time::MillisecondsToMicroseconds(Config::Profile::BENCHMARK_FREQUENCY)) { _lastBenchmarkTimeStamp = elapsedTime; _lastBenchmarkReport = Util::StringFormat(Locale::get(_ID("FRAMERATE_FPS_OUTPUT")), _frameRateHandler.frameRate(), _frameRateHandler.averageFrameRate(), _frameRateHandler.maxFrameRate(), _frameRateHandler.minFrameRate(), _frameRateHandler.frameTime()); } } }
void SceneAnimator::load(PlatformContext& context, ByteBuffer& dataIn) { // make sure to clear this before writing new data release(); _skeleton = loadSkeleton(dataIn, nullptr); stringImpl boneName; uint32_t nsize = 0; dataIn >> nsize; _bones.resize(nsize); for (uint32_t i(0); i < nsize; i++) { dataIn >> boneName; _bones[i] = _skeleton->find(boneName); } _skeletonDepthCache = nsize; // the number of animations dataIn >> nsize; _animations.resize(nsize); uint32_t idx = 0; for (std::shared_ptr<AnimEvaluator>& anim : _animations) { anim = std::make_unique<AnimEvaluator>(); AnimEvaluator::load(*anim, dataIn); // get all the animation names so I can reference them by name and get the correct id hashAlg::insert(_animationNameToID, _ID(anim->name().c_str()), idx++); } init(context); }
VertexBuffer* GFXDevice::newVB() const { bool locked = _gpuObjectArenaMutex.try_lock(); VertexBuffer* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new vertex array (VAO + VB + IB). /// The callee is responsible for it's deletion! temp = new (_gpuObjectArena) glVertexArray(refThis(this)); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkVertexBuffer(refThis(this)); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noVertexBuffer(refThis(this)); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
bool CMenuPlot::IsDeleteEnabled() { bool bRtn = false; if(!m_bPreview) { bRtn = IsEnabled(_ID(IDmenuPlotRemove)); } return bRtn; }
bool CMenuPlot::IsAppendEnabled() { bool bRtn = false; if(!m_bPreview) { bRtn = IsEnabled(_ID(IDmenuPlotAppend)); } return bRtn; }
bool CMenuPlot::SyncValue() { bool bRtn = false; if(!m_bPreview) { bRtn = IsChecked(_ID(IDmenuPlotSync)); } return bRtn; }
void LocalClient::HandlePongOpCode(WorldPacket& p) { F32 time = 0; p >> time; D64 result = Time::ElapsedMilliseconds() - time; ParamHandler::instance().setParam( _ID("serverResponse"), "Server says: Pinged with : " + to_stringImpl(floor(result + 0.5f)) + " ms latency"); }
bool Texture::loadFile(const TextureLoadInfo& info, const stringImpl& name, ImageTools::ImageData& fileData) { // If we haven't already loaded this file, do so if (!fileData.data()) { // Flip image if needed fileData.flip(_flipped); fileData.set16Bit(_descriptor.dataType() == GFXDataFormat::FLOAT_16 || _descriptor.dataType() == GFXDataFormat::SIGNED_SHORT || _descriptor.dataType() == GFXDataFormat::UNSIGNED_SHORT); // Save file contents in the "img" object ImageTools::ImageDataInterface::CreateImageData(name, fileData); bufferPtr data = fileData.is16Bit() ? fileData.data16() : fileData.isHDR() ? fileData.dataf() : fileData.data(); // Validate data if (data == nullptr) { if (info._layerIndex > 0) { Console::errorfn(Locale::get(_ID("ERROR_TEXTURE_LAYER_LOAD")), name.c_str()); return false; } Console::errorfn(Locale::get(_ID("ERROR_TEXTURE_LOAD")), name.c_str()); // Missing texture fallback. fileData.flip(false); // missing_texture.jpg must be something that really stands out ImageTools::ImageDataInterface::CreateImageData(Paths::g_assetsLocation + Paths::g_texturesLocation + s_missingTextureFileName, fileData); } // Extract width, height and bitdepth U16 width = fileData.dimensions().width; U16 height = fileData.dimensions().height; // If we have an alpha channel, we must check for translucency/transparency FileWithPath fwp = splitPathToNameAndLocation(name); Util::ReplaceStringInPlace(fwp._path, "/", "_"); const stringImpl cachePath = Paths::g_cacheLocation + Paths::Textures::g_metadataLocation; const stringImpl cacheName = fwp._path + "_" + fwp._fileName + ".cache"; ByteBuffer metadataCache; if (metadataCache.loadFromFile(cachePath, cacheName)) { metadataCache >> _hasTransparency; metadataCache >> _hasTranslucency; } else {
void SceneRenderState::toggleAxisLines() { static U32 selection = 0; Console::d_printfn(Locale::get(_ID("TOGGLE_SCENE_AXIS_GIZMO"))); selection = (selection + 1) % to_base(GizmoState::COUNT); switch (selection) { case 0: gizmoState(GizmoState::SELECTED_GIZMO); break; case 1: gizmoState(GizmoState::ALL_GIZMO); break; case 2: gizmoState(GizmoState::SCENE_GIZMO); break; case 3: gizmoState(GizmoState::NO_GIZMO); break; } }
void LocalClient::handlePacket(WorldPacket& p) { switch (p.opcode()) { case OPCodes::MSG_HEARTBEAT: HandleHeartBeatOpCode(p); break; case OPCodesEx::SMSG_PONG: HandlePongOpCode(p); break; case OPCodes::SMSG_DISCONNECT: HandleDisconnectOpCode(p); break; case OPCodesEx::SMSG_GEOMETRY_APPEND: HandleGeometryAppendOpCode(p); break; default: ParamHandler::instance().setParam(_ID("serverResponse"), "Unknown OpCode: [ 0x" + to_stringImpl(p.opcode()) + " ]"); break; }; }
void LocalClient::HandleGeometryAppendOpCode(WorldPacket& p) { Console::printfn(Locale::get(_ID("ASIO_PAK_REC_GEOM_APPEND"))); U8 size; p >> size; /*vector<FileData> patch; for (U8 i = 0; i < size; i++) { FileData d; p >> d.ItemName; p >> d.ModelName; p >> d.orientation.x; p >> d.orientation.y; p >> d.orientation.z; p >> d.position.x; p >> d.position.y; p >> d.position.z; p >> d.scale.x; p >> d.scale.y; p >> d.scale.z; patch.push_back(d); } _parentScene.addPatch(patch);*/ }
Texture* GFXDevice::newTexture(size_t descriptorHash, const stringImpl& name, const stringImpl& resourceName, const stringImpl& resourceLocation, bool isFlipped, bool asyncLoad, const TextureDescriptor& texDescriptor) const { bool locked = _gpuObjectArenaMutex.try_lock(); // Texture is a resource! Do not use object arena! Texture* temp = nullptr; switch (_API_ID) { case RenderAPI::OpenGL: case RenderAPI::OpenGLES: { /// Create and return a new texture. The callee is responsible for it's deletion! temp = new (_gpuObjectArena) glTexture(refThis(this), descriptorHash, name, resourceName, resourceLocation, isFlipped, asyncLoad, texDescriptor); } break; case RenderAPI::Vulkan: { temp = new (_gpuObjectArena) vkTexture(refThis(this), descriptorHash, name, resourceName, resourceLocation, isFlipped, asyncLoad, texDescriptor); } break; case RenderAPI::None: { temp = new (_gpuObjectArena) noTexture(refThis(this), descriptorHash, name, resourceName, resourceLocation, isFlipped, asyncLoad, texDescriptor); } break; default: { DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API"))); } break; }; if (temp != nullptr) { _gpuObjectArena.DTOR(temp); } if (locked) { _gpuObjectArenaMutex.unlock(); } return temp; }
glPixelBuffer::glPixelBuffer(GFXDevice& context, PBType type, const char* name) : PixelBuffer(context, type, name) , _dataType(GL_NONE) , _format(GL_NONE) , _internalFormat(GL_NONE) , _dataSizeBytes(0) , _bufferSize(0) { switch (_pbtype) { case PBType::PB_TEXTURE_1D: _textureType = TextureType::TEXTURE_1D; break; case PBType::PB_TEXTURE_2D: _textureType = TextureType::TEXTURE_2D; break; case PBType::PB_TEXTURE_3D: _textureType = TextureType::TEXTURE_3D; break; default: Console::errorfn(Locale::get(_ID("ERROR_PB_INVALID_TYPE"))); break; }; }
bool glPixelBuffer::create(GLushort width, GLushort height, GLushort depth, GFXImageFormat formatEnum, GFXDataFormat dataTypeEnum) { GLenum textureTypeEnum = GLUtil::glTextureTypeTable[to_U32(_textureType)]; _internalFormat = GLUtil::internalFormat(formatEnum, dataTypeEnum, false); _format = GLUtil::glImageFormatTable[to_U32(formatEnum)]; _dataType = GLUtil::glDataFormat[to_U32(dataTypeEnum)]; Console::printfn(Locale::get(_ID("GL_PB_GEN")), width, height); _width = width; _height = height; _depth = depth; _bufferSize = _width * 4; switch (_pbtype) { case PBType::PB_TEXTURE_2D: _bufferSize *= _height; break; case PBType::PB_TEXTURE_3D: _bufferSize *= _height * _depth; break; }; switch (_dataType) { case GL_SHORT: case GL_HALF_FLOAT: case GL_UNSIGNED_SHORT: _dataSizeBytes = 2; break; case GL_FLOAT: case GL_INT: case GL_UNSIGNED_INT: _dataSizeBytes = 4; break; default: break; } _bufferSize *= _dataSizeBytes; GL_API::deleteTextures(1, &_textureID, _textureType); glCreateTextures(textureTypeEnum, 1, &_textureID); glTextureParameteri(_textureID, GL_GENERATE_MIPMAP, 0); glTextureParameteri(_textureID, GL_TEXTURE_MIN_FILTER, to_I32(GL_NEAREST)); glTextureParameteri(_textureID, GL_TEXTURE_MAG_FILTER, to_I32(GL_NEAREST)); glTextureParameteri(_textureID, GL_TEXTURE_BASE_LEVEL, 0); glTextureParameteri(_textureID, GL_TEXTURE_MAX_LEVEL, 1000); glTextureParameteri(_textureID, GL_TEXTURE_WRAP_S, to_I32(GL_REPEAT)); if (_pbtype != PBType::PB_TEXTURE_1D) { glTextureParameteri(_textureID, GL_TEXTURE_WRAP_T, to_I32(GL_REPEAT)); } if (_pbtype == PBType::PB_TEXTURE_3D) { glTextureParameteri(_textureID, GL_TEXTURE_WRAP_R, to_I32(GL_REPEAT)); } U16 mipLevels = to_U16(std::floor(std::log2(std::max(_width, _height))) + 1); GL_API::getStateTracker().setPixelPackUnpackAlignment(); switch (_pbtype) { case PBType::PB_TEXTURE_1D: glTextureStorage1D(_textureID, mipLevels, _internalFormat, _width); break; case PBType::PB_TEXTURE_2D: glTextureStorage2D(_textureID, mipLevels, _internalFormat, _width, _height); break; case PBType::PB_TEXTURE_3D: glTextureStorage3D(_textureID, mipLevels, _internalFormat, _width, _height, _depth); break; }; if (_pixelBufferHandle > 0) { GLUtil::freeBuffer(_pixelBufferHandle); } GLUtil::createAndAllocBuffer(_bufferSize, GL_STREAM_DRAW, _pixelBufferHandle, NULL, _name.empty() ? nullptr : _name.c_str()); return _pixelBufferHandle != 0 && _textureID != 0; }
/// Load texture data using the specified file name void Texture::threadedLoad(DELEGATE_CBK<void, CachedResource_wptr> onLoadCallback) { TextureLoadInfo info; // Each texture face/layer must be in a comma separated list stringstreamImpl textureLocationList(assetLocation()); stringstreamImpl textureFileList(assetName()); bool loadFromFile = false; vector<stringImpl> fileNames; // We loop over every texture in the above list and store it in this // temporary string stringImpl currentTextureFile; stringImpl currentTextureLocation; stringImpl currentTextureFullPath; while (std::getline(textureLocationList, currentTextureLocation, ',') && std::getline(textureFileList, currentTextureFile, ',')) { Util::Trim(currentTextureFile); // Skip invalid entries if (!currentTextureFile.empty()) { fileNames.push_back( (currentTextureLocation.empty() ? Paths::g_texturesLocation : currentTextureLocation) + "/" + currentTextureFile); _descriptor._sourceFileList.push_back(currentTextureFile); } } loadFromFile = !fileNames.empty(); hashMap<U64, ImageTools::ImageData> dataStorage; for(const stringImpl& file : fileNames) { // Attempt to load the current entry if (!loadFile(info, file, dataStorage[_ID(file.c_str())])) { // Invalid texture files are not handled yet, so stop loading return; } info._layerIndex++; if (_textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._layerIndex == 6) { info._layerIndex = 0; info._cubeMapCount++; } } } if (loadFromFile) { if (_textureData._textureType == TextureType::TEXTURE_CUBE_MAP || _textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._layerIndex != 6) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_CUBMAP_INIT_COUNT")), resourceName().c_str()); return; } } if (_textureData._textureType == TextureType::TEXTURE_2D_ARRAY || _textureData._textureType == TextureType::TEXTURE_2D_ARRAY_MS) { if (info._layerIndex != _numLayers) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_ARRAY_INIT_COUNT")), resourceName().c_str()); return; } } if (_textureData._textureType == TextureType::TEXTURE_CUBE_ARRAY) { if (info._cubeMapCount != _numLayers) { Console::errorfn( Locale::get(_ID("ERROR_TEXTURE_LOADER_ARRAY_INIT_COUNT")), resourceName().c_str()); return; } } } }
void CMenuPlot::ShowMinRfu(bool b) { Check(_ID(IDmenuPlotRFU),b); }
void CMenuPlot::ShowLadderLabels(bool b) { Check(_ID(IDmenuPlotLadderLabels),b); }
int CMenuArtifact::_Ndx2MenuID(int ndx) { return _ID(CArtifactDisplayList::anMenuID[ndx]); }
void AnimEvaluator::load(AnimEvaluator& evaluator, ByteBuffer& dataIn) { Console::d_printfn(Locale::get(_ID("CREATE_ANIMATION_BEGIN")), evaluator._name.c_str()); // the animation name dataIn >> evaluator._name; // the duration dataIn >> evaluator._duration; // the number of ticks per second dataIn >> evaluator._ticksPerSecond; // the number animation channels uint32_t nsize = 0; dataIn >> nsize; evaluator._channels.resize(nsize); evaluator._lastPositions.resize(nsize, vec3<U32>()); // for each channel for (vec_size j(0); j < evaluator._channels.size(); j++) { AnimationChannel& channel = evaluator._channels[j]; //the channel name dataIn >> channel._name; dataIn >> channel._nameKey; // the number of position keys dataIn >> nsize; channel._positionKeys.resize(nsize); // for each position key for (vec_size i(0); i < nsize; i++) { aiVectorKey& pos = channel._positionKeys[i]; // position key dataIn >> pos.mTime; // position key dataIn >> pos.mValue.x; dataIn >> pos.mValue.y; dataIn >> pos.mValue.z; } // the number of rotation keys dataIn >> nsize; channel._rotationKeys.resize(nsize); // for each rotation key for (vec_size i(0); i < nsize; i++) { aiQuatKey& rot = channel._rotationKeys[i]; // rotation key dataIn >> rot.mTime; // rotation key dataIn >> rot.mValue.x; dataIn >> rot.mValue.y; dataIn >> rot.mValue.z; dataIn >> rot.mValue.w; } // the number of scaling keys dataIn >> nsize; channel._scalingKeys.resize(nsize); // for each skaling key for (vec_size i(0); i < nsize; i++) { aiVectorKey& scale = channel._scalingKeys[i]; // scale key dataIn >> scale.mTime; // scale key dataIn >> scale.mValue.x; dataIn >> scale.mValue.y; dataIn >> scale.mValue.z; } } evaluator._lastPositions.resize(evaluator._channels.size(), vec3<U32>()); }