Refactor chunk rendering related class names and file structure

This commit is contained in:
Erik Broberg
2016-10-26 18:15:31 +02:00
parent 21b41e3ec0
commit 9f65907579
15 changed files with 88 additions and 99 deletions

View File

@@ -31,7 +31,6 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunknode.h
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.h
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunkrenderer.h
${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.h
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.h
@@ -52,7 +51,6 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/gpustructs.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tilepile.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/chunktile.h
@@ -64,11 +62,12 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledepthtransform.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/layermanager.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.h
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.h
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.h
@@ -85,7 +84,6 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunknode.cpp
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunk.cpp
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunkrenderer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/chunk/culling.cpp
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunklevelevaluator.cpp
@@ -105,8 +103,6 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/texttileprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/gpustructs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tilepile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/chunktile.cpp
@@ -117,11 +113,12 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tiledatatype.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/layermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunkrenderer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layershadermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/layermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gpulayermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl

View File

@@ -30,14 +30,14 @@
#include <stack>
#include <memory>
#include <ostream>
#include <functional>
#include <modules/globebrowsing/tile/tileindex.h>
#include <modules/globebrowsing/chunk/chunk.h>
#include <modules/globebrowsing/chunk/chunkrenderer.h>
#include <modules/globebrowsing/rendering/chunkrenderer.h>
#include <modules/globebrowsing/geometry/geodetic2.h>
#include <functional>
namespace openspace {
namespace globebrowsing {

View File

@@ -37,8 +37,8 @@
#include <modules/globebrowsing/geometry/ellipsoid.h>
#include <modules/globebrowsing/chunk/chunknode.h>
#include <modules/globebrowsing/chunk/chunkrenderer.h>
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <modules/globebrowsing/rendering/chunkrenderer.h>
#include <modules/globebrowsing/other/statscollector.h>
namespace openspace {

View File

@@ -22,12 +22,10 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <ghoul/misc/threadpool.h>
#include <modules/globebrowsing/tile/tileselector.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/rendering/layermanager.h>
// open space includes
#include <openspace/engine/openspaceengine.h>
@@ -39,6 +37,7 @@
// ghoul includes
#include <ghoul/misc/assert.h>
#include <ghoul/misc/threadpool.h>
namespace {
const std::string _loggerCat = "RenderableGlobe";

View File

@@ -22,12 +22,12 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/chunk/chunkrenderer.h>
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/tile/chunktile.h>
#include <modules/globebrowsing/rendering/chunkrenderer.h>
#include <modules/globebrowsing/rendering/layermanager.h>
// open space includes
#include <openspace/engine/wrapper/windowwrapper.h>
@@ -64,12 +64,12 @@ namespace globebrowsing {
: _layerManager(layerManager)
, _grid(grid)
{
_globalRenderingShaderProvider = std::make_shared<LayeredTextureShaderProvider>(
_globalLayerShaderManager = std::make_shared<LayerShaderManager>(
"GlobalChunkedLodPatch",
"${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_vs.glsl",
"${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_fs.glsl");
_localRenderingShaderProvider = std::make_shared<LayeredTextureShaderProvider>(
_localLayerShaderManager = std::make_shared<LayerShaderManager>(
"LocalChunkedLodPatch",
"${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_vs.glsl",
"${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_fs.glsl");
@@ -94,16 +94,16 @@ namespace globebrowsing {
}
ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
LayeredTextureShaderProvider* layeredTextureShaderProvider,
LayerShaderManager* layeredTextureShaderProvider,
GPULayerManager * gpuLayerManager,
const Chunk& chunk)
{
const TileIndex& tileIndex = chunk.tileIndex();
LayeredTexturePreprocessingData layeredTexturePreprocessingData;
LayerShaderPreprocessingData layeredTexturePreprocessingData;
for (size_t i = 0; i < LayerManager::NUM_LAYER_GROUPS; i++) {
LayeredTextureInfo layeredTextureInfo;
LayerGroupPreprocessingData layeredTextureInfo;
auto layerGroup = _layerManager->layerGroup(i);
layeredTextureInfo.lastLayerIdx = layerGroup.activeLayers().size() - 1;
layeredTextureInfo.layerBlendingEnabled = layerGroup.layerBlendingEnabled();
@@ -124,7 +124,7 @@ namespace globebrowsing {
// Now the shader program can be accessed
ProgramObject* programObject =
layeredTextureShaderProvider->getUpdatedShaderProgram(
layeredTextureShaderProvider->programObject(
layeredTexturePreprocessingData);
if (layeredTextureShaderProvider->updatedOnLastCall()) {
@@ -151,7 +151,7 @@ namespace globebrowsing {
void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){
ProgramObject* programObject = getActivatedProgramWithTileData(
_globalRenderingShaderProvider.get(),
_globalLayerShaderManager.get(),
_globalGpuLayerManager.get(),
chunk);
if (programObject == nullptr) {
@@ -221,7 +221,7 @@ namespace globebrowsing {
void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data) {
ProgramObject* programObject = getActivatedProgramWithTileData(
_localRenderingShaderProvider.get(),
_localLayerShaderManager.get(),
_localGpuLayerManager.get(),
chunk);
if (programObject == nullptr) {

View File

@@ -30,15 +30,11 @@
// open space includes
#include <openspace/rendering/renderable.h>
#include <modules/globebrowsing/geometry/geodetic2.h>
#include <modules/globebrowsing/geometry/ellipsoid.h>
#include <modules/globebrowsing/meshes/grid.h>
#include <modules/globebrowsing/layered_rendering/layeredtextureshaderprovider.h>
#include <modules/globebrowsing/rendering/layershadermanager.h>
#include <modules/globebrowsing/tile/tileselector.h>
#include <modules/globebrowsing/chunk/chunknode.h>
#include <ghoul/opengl/textureunit.h>
@@ -91,7 +87,7 @@ namespace globebrowsing {
ProgramObject* getActivatedProgramWithTileData(
LayeredTextureShaderProvider* layeredTextureShaderProvider,
LayerShaderManager* layeredTextureShaderProvider,
GPULayerManager * gpuLayerManager,
const Chunk& chunk);
@@ -100,8 +96,8 @@ namespace globebrowsing {
std::shared_ptr<LayerManager> _layerManager;
// Two different shader programs. One for global and one for local rendering.
std::shared_ptr<LayeredTextureShaderProvider> _globalRenderingShaderProvider;
std::shared_ptr<LayeredTextureShaderProvider> _localRenderingShaderProvider;
std::shared_ptr<LayerShaderManager> _globalLayerShaderManager;
std::shared_ptr<LayerShaderManager> _localLayerShaderManager;
// Layered texture uniforms are chached in the uniform ID handles.
std::shared_ptr<GPULayerManager> _globalGpuLayerManager;

View File

@@ -22,12 +22,13 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/tile/gpustructs.h>
#include <modules/globebrowsing/tile/tileIndex.h>
#include <modules/globebrowsing/tile/chunktile.h>
#include <modules/globebrowsing/tile/tileselector.h>
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/rendering/gpulayermanager.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/assert.h>
@@ -39,7 +40,7 @@
#include <memory>
namespace {
const std::string _loggerCat = "GPUStructs";
const std::string _loggerCat = "GPULayerManager";
}
namespace openspace {

View File

@@ -22,13 +22,14 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef GPU_STRUCTS_H
#define GPU_STRUCTS_H
#ifndef __GPU_LAYER_MANAGER_H__
#define __GPU_LAYER_MANAGER_H__
#include <openspace/util/gpudata.h>
#include <modules/globebrowsing/tile/tileindex.h>
#include <modules/globebrowsing/tile/chunktile.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <openspace/util/gpudata.h>
#include <glm/glm.hpp>
@@ -161,4 +162,4 @@ private:
} // namespace globebrowsing
} // namespace openspace
#endif // GPU_STRUCTS_H
#endif // __GPU_LAYER_MANAGER_H__

View File

@@ -23,11 +23,10 @@
****************************************************************************************/
#include <openspace/util/factorymanager.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <openspace/properties/scalarproperty.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <ghoul/logging/logmanager.h>
#include "cpl_minixml.h"

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __TILE_PROVIDER_MANAGER_H__
#define __TILE_PROVIDER_MANAGER_H__
#ifndef __LAYER_MANAGER_H__
#define __LAYER_MANAGER_H__
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
@@ -145,4 +145,4 @@ namespace globebrowsing {
} // namespace globebrowsing
} // namespace openspace
#endif // __TILE_PROVIDER_MANAGER_H__
#endif // __LAYER_MANAGER_H__

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/layered_rendering/layeredtextureshaderprovider.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/rendering/layershadermanager.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/engine/openspaceengine.h>
@@ -33,19 +33,19 @@
#include <string>
namespace {
const std::string _loggerCat = "LayeredTextureShaderProvider";
const std::string _loggerCat = "LayerShaderManager";
}
namespace openspace {
namespace globebrowsing {
bool LayeredTextureInfo::operator==(const LayeredTextureInfo& other) const {
bool LayerGroupPreprocessingData::operator==(const LayerGroupPreprocessingData& other) const {
return lastLayerIdx == other.lastLayerIdx &&
layerBlendingEnabled == other.layerBlendingEnabled;
}
bool LayeredTexturePreprocessingData::operator==(
const LayeredTexturePreprocessingData& other) const
bool LayerShaderPreprocessingData::operator==(
const LayerShaderPreprocessingData& other) const
{
if (layeredTextureInfo.size() != other.layeredTextureInfo.size() ||
@@ -64,7 +64,7 @@ namespace globebrowsing {
}
}
LayeredTextureShaderProvider::LayeredTextureShaderProvider(
LayerShaderManager::LayerShaderManager(
const std::string& shaderName,
const std::string& vsPath,
const std::string& fsPath)
@@ -72,10 +72,11 @@ namespace globebrowsing {
, _vsPath(vsPath)
, _fsPath(fsPath)
, _updatedOnLastCall(false)
{}
LayeredTextureShaderProvider::~LayeredTextureShaderProvider()
{
}
LayerShaderManager::~LayerShaderManager() {
if (_programObject) {
RenderEngine& renderEngine = OsEng.renderEngine();
renderEngine.removeRenderProgram(_programObject);
@@ -83,8 +84,8 @@ namespace globebrowsing {
}
}
ProgramObject* LayeredTextureShaderProvider::getUpdatedShaderProgram(
LayeredTexturePreprocessingData preprocessingData)
ProgramObject* LayerShaderManager::programObject(
LayerShaderPreprocessingData preprocessingData)
{
_updatedOnLastCall = false;
if (!(preprocessingData == _preprocessingData) || _programObject == nullptr) {
@@ -94,8 +95,8 @@ namespace globebrowsing {
return _programObject.get();
}
void LayeredTextureShaderProvider::recompileShaderProgram(
LayeredTexturePreprocessingData preprocessingData)
void LayerShaderManager::recompileShaderProgram(
LayerShaderPreprocessingData preprocessingData)
{
_preprocessingData = preprocessingData;
ghoul::Dictionary shaderDictionary;
@@ -133,7 +134,7 @@ namespace globebrowsing {
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
}
bool LayeredTextureShaderProvider::updatedOnLastCall() {
bool LayerShaderManager::updatedOnLastCall() {
return _updatedOnLastCall;
}

View File

@@ -22,11 +22,11 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __LAYERED_TEXTURE_SHADER_PROVIDER__
#define __LAYERED_TEXTURE_SHADER_PROVIDER__
#ifndef __LAYER_SHADER_MANAGER_H__
#define __LAYER_SHADER_MANAGER_H__
#include <modules/globebrowsing/tile/gpustructs.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <modules/globebrowsing/rendering/gpulayermanager.h>
#include "ghoul/opengl/programobject.h"
@@ -44,43 +44,38 @@ namespace globebrowsing {
/**
* Settings per texture category that contains shader preprocessing information.
*/
struct LayeredTextureInfo
{
struct LayerGroupPreprocessingData {
int lastLayerIdx;
bool layerBlendingEnabled;
bool operator==(const LayeredTextureInfo& other) const;
bool operator==(const LayerGroupPreprocessingData& other) const;
};
/**
* Data needed for shader preprocessing before compiling a layered texture shader
* program.
*
* If a <code>LayeredTexturePreprocessingData</code> is compared with another it can
* be determined wheter or not a <code>LayeredTextureShaderProvider</code> needs to
* If a <code>LayerShaderPreprocessingData</code> is compared with another it can
* be determined wheter or not a <code>LayerShaderManager</code> needs to
* recompile its shader program. For each <code>TextureCategory</code> there is
* information about how many layers it has and whether or not to blend the texture
* levels.
*/
struct LayeredTexturePreprocessingData {
std::array<LayeredTextureInfo, LayerManager::NUM_LAYER_GROUPS>
layeredTextureInfo;
struct LayerShaderPreprocessingData {
std::array<LayerGroupPreprocessingData, LayerManager::NUM_LAYER_GROUPS> layeredTextureInfo;
std::vector<std::pair<std::string, std::string> > keyValuePairs;
bool operator==(const LayeredTexturePreprocessingData& other) const;
bool operator==(const LayerShaderPreprocessingData& other) const;
};
/**
* This class has ownership of an updated shader program for rendering tiles.
*/
class LayeredTextureShaderProvider
{
class LayerShaderManager {
public:
LayeredTextureShaderProvider(
LayerShaderManager(
const std::string& shaderName,
const std::string& vsPath,
const std::string& fsPath);
~LayeredTextureShaderProvider();
~LayerShaderManager();
/**
* Returns a pointer to a <code>ProgramObject</code> for rendering tiles.
@@ -89,17 +84,17 @@ namespace globebrowsing {
* from the last time this function was called the shader program will be
* recompiled before returned.
*/
ProgramObject* getUpdatedShaderProgram(
LayeredTexturePreprocessingData preprocessingData);
ProgramObject* programObject(
LayerShaderPreprocessingData preprocessingData);
bool updatedOnLastCall();
private:
void recompileShaderProgram(LayeredTexturePreprocessingData preprocessingData);
void recompileShaderProgram(LayerShaderPreprocessingData preprocessingData);
std::unique_ptr<ProgramObject> _programObject;
LayeredTexturePreprocessingData _preprocessingData;
LayerShaderPreprocessingData _preprocessingData;
const std::string _shaderName;
const std::string _vsPath;
@@ -112,4 +107,4 @@ namespace globebrowsing {
} // namespace globebrowsing
} // namespace openspace
#endif // __LAYERED_TEXTURE_SHADER_PROVIDER__
#endif // __LAYER_SHADER_MANAGER_H__

View File

@@ -28,12 +28,12 @@
#include <${MODULE_GLOBEBROWSING}/shaders/tile.hglsl>
#include <${MODULE_GLOBEBROWSING}/shaders/blending.hglsl>
// First layer type from LayeredTextureShaderProvider is height map
// First layer type from LayerShaderManager is height map
#define NUMLAYERS_HEIGHTMAP #{lastLayerIndexHeightMaps} + 1
#define USE_HEIGHTMAP #{useHeightMaps}
#define HEIGHTMAP_BLENDING_ENABLED #{blendHeightMaps}
// Second layer type from LayeredTextureShaderProvider is color texture
// Second layer type from LayerShaderManager is color texture
#define NUMLAYERS_COLORTEXTURE #{lastLayerIndexColorTextures} + 1
#define USE_COLORTEXTURE #{useColorTextures}
#define COLORTEXTURE_BLENDING_ENABLED #{blendColorTextures}
@@ -42,22 +42,22 @@
#define USE_GRAYSCALETEXTURE #{useGrayScaleTextures}
#define GRAYSCALETEXTURE_BLENDING_ENABLED #{blendGrayScaleTextures}
// Third layer type from LayeredTextureShaderProvider is water mask
// Third layer type from LayerShaderManager is water mask
#define NUMLAYERS_WATERMASK #{lastLayerIndexWaterMasks} + 1
#define USE_WATERMASK #{useWaterMasks}
#define WATERMASK_BLENDING_ENABLED #{blendWaterMasks}
// Fourth layer type from LayeredTextureShaderProvider is night texture
// Fourth layer type from LayerShaderManager is night texture
#define NUMLAYERS_NIGHTTEXTURE #{lastLayerIndexNightTextures} + 1
#define USE_NIGHTTEXTURE #{useNightTextures}
#define NIGHTTEXTURE_BLENDING_ENABLED #{blendNightTextures}
// Fifth layer type from LayeredTextureShaderProvider is overlay
// Fifth layer type from LayerShaderManager is overlay
#define NUMLAYERS_OVERLAY #{lastLayerIndexOverlays} + 1
#define USE_OVERLAY #{useOverlays}
#define OVERLAY_BLENDING_ENABLED #{blendOverlays}
// Sixth layer type from LayeredTextureShaderProvider is grayscale overlay
// Sixth layer type from LayerShaderManager is grayscale overlay
#define NUMLAYERS_GRAYSCALE_OVERLAY #{lastLayerIndexGrayScaleOverlays} + 1
#define USE_GRAYSCALE_OVERLAY #{useGrayScaleOverlays}
#define GRAYSCALE_OVERLAY_BLENDING_ENABLED #{blendGrayScaleOverlays}

View File

@@ -681,7 +681,6 @@ namespace globebrowsing {
PixelRegion gdalRegion = gdalPixelRegion(rasterBand);
ghoul_assert(io.read.region.isInside(gdalRegion), "write region of bounds!");
ghoul_assert(io.write.region.start.x >= 0 && io.write.region.start.y >= 0, "Invalid write region");
PixelCoordinate end = io.write.region.end();

View File

@@ -28,8 +28,9 @@
#include <modules/globebrowsing/tile/tileindex.h>
#include <modules/globebrowsing/tile/tile.h>
#include <modules/globebrowsing/tile/layermanager.h>
#include <modules/globebrowsing/tile/chunktile.h>
#include <modules/globebrowsing/rendering/layermanager.h>
#include <vector>
namespace openspace {