mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-29 15:29:26 -05:00
Refactor: CPU to GPU mapping of all Layer data
This commit is contained in:
@@ -115,17 +115,26 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Layer
|
||||
|
||||
void GPULayer::setValue(ProgramObject* programObject, const Layer& layer, const TileIndex& tileIndex, int pileSize){
|
||||
ChunkTilePile chunkTilePile = layer.getChunkTilePile(tileIndex, pileSize);
|
||||
gpuChunkTilePile.setValue(programObject, chunkTilePile);
|
||||
|
||||
// do settings
|
||||
/*for(int i = 0; i<layer.layerSettings.size(); ++i){
|
||||
layer.layerSettings[i]->setValue(programObject);
|
||||
}*/
|
||||
}
|
||||
|
||||
void GPULayer::updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize){
|
||||
gpuChunkTilePile.updateUniformLocations(programObject, nameBase, pileSize);
|
||||
gpuChunkTilePile.updateUniformLocations(programObject, nameBase + "pile.", pileSize);
|
||||
|
||||
// do settings
|
||||
/*for(int i = 0; i<layer.layerSettings.size(); ++i){
|
||||
layer.layerSettings[i]->updateUniformLocations(programObject, nameBase);
|
||||
}*/
|
||||
}
|
||||
|
||||
void GPULayer::deactivate(){
|
||||
@@ -142,11 +151,11 @@ namespace globebrowsing {
|
||||
|
||||
void GPUHeightLayer::updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize){
|
||||
GPULayer::updateUniformLocations(programObject, nameBase, pileSize);
|
||||
gpuDepthTransform.updateUniformLocations(programObject, nameBase);
|
||||
gpuDepthTransform.updateUniformLocations(programObject, nameBase + "depthTransform.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// LayerGroup
|
||||
|
||||
void GPULayerGroup::setValue(ProgramObject* programObject, const LayerGroup& layerGroup, const TileIndex& tileIndex, int pileSize){
|
||||
@@ -157,10 +166,13 @@ namespace globebrowsing {
|
||||
}
|
||||
}
|
||||
|
||||
void GPULayerGroup::updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize, int numActiveLayers){
|
||||
void GPULayerGroup::updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize, int numActiveLayers, int category){
|
||||
gpuActiveLayers.resize(numActiveLayers);
|
||||
for (size_t i = 0; i < gpuActiveLayers.size(); ++i){
|
||||
gpuActiveLayers[i] = std::make_unique<GPULayer>();
|
||||
// should maybe a proper GPULayer factory
|
||||
gpuActiveLayers[i] = category == LayeredTextures::TextureCategory::HeightMaps ?
|
||||
std::make_unique<GPUHeightLayer>() :
|
||||
std::make_unique<GPULayer>();
|
||||
std::string nameExtension = "[" + std::to_string(i) + "].";
|
||||
gpuActiveLayers[i]->updateUniformLocations(programObject, nameBase + nameExtension, pileSize);
|
||||
}
|
||||
@@ -173,12 +185,5 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
class LayerSettings;
|
||||
class GPULayerSettings{
|
||||
public:
|
||||
@@ -108,9 +108,11 @@ public:
|
||||
void deactivate();
|
||||
|
||||
private:
|
||||
|
||||
GPUData<float> gpuOpacity;
|
||||
GPUData<float> gpuGamma;
|
||||
GPUData<float> gpuMultiplier;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class Layer;
|
||||
@@ -121,7 +123,6 @@ public:
|
||||
virtual void deactivate();
|
||||
private:
|
||||
GPUChunkTilePile gpuChunkTilePile;
|
||||
GPULayerSettings gpuLayerSettings;
|
||||
};
|
||||
|
||||
class GPUHeightLayer : public GPULayer{
|
||||
@@ -139,7 +140,7 @@ class GPULayerGroup{
|
||||
public:
|
||||
|
||||
virtual void setValue(ProgramObject* programObject, const LayerGroup& layerGroup, const TileIndex& tileIndex, int pileSize);
|
||||
virtual void updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize, int numActiveLayers);
|
||||
virtual void updateUniformLocations(ProgramObject* programObject, const std::string& nameBase, int pileSize, int numActiveLayers, int category);
|
||||
virtual void deactivate();
|
||||
private:
|
||||
std::vector<std::unique_ptr<GPULayer>> gpuActiveLayers;
|
||||
|
||||
@@ -39,6 +39,26 @@ namespace {
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
FloatLayerSetting::FloatLayerSetting(properties::FloatProperty floatProp)
|
||||
: _property(floatProp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FloatLayerSetting::setValue(ProgramObject* programObject){
|
||||
gpuData.setValue(programObject, _property.value());
|
||||
}
|
||||
|
||||
void FloatLayerSetting::updateUniformLocations(ProgramObject* programObject, const std::string& nameBase){
|
||||
gpuData.updateUniformLocations(programObject, nameBase + _property.identifier());
|
||||
}
|
||||
|
||||
properties::Property* FloatLayerSetting::property() {
|
||||
return &_property;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ChunkTilePile Layer::getChunkTilePile(const TileIndex& tileIndex, int pileSize) const{
|
||||
return std::move(TileSelector::getHighestResolutionTilePile(tileProvider.get(), tileIndex, pileSize));
|
||||
|
||||
@@ -43,15 +43,30 @@
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
|
||||
template<typename T> class LayerSetting;
|
||||
|
||||
class ILayerSetting{
|
||||
class LayerSetting{
|
||||
public:
|
||||
virtual void setValue(ProgramObject* programObject) = 0;
|
||||
virtual void updateUniformLocations(ProgramObject* programObject) = 0;
|
||||
virtual void deactivate() { };
|
||||
virtual properties::Property* property() const = 0;
|
||||
};
|
||||
|
||||
class FloatLayerSetting : public LayerSetting {
|
||||
public:
|
||||
FloatLayerSetting(properties::FloatProperty);
|
||||
virtual void setValue(ProgramObject* programObject);
|
||||
virtual void updateUniformLocations(ProgramObject* programObject, const std::string& nameBase);
|
||||
virtual properties::Property* property();
|
||||
|
||||
private:
|
||||
properties::FloatProperty _property;
|
||||
GPUData<float> gpuData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
template<typename T>
|
||||
class LayerSetting : public ILayerSetting {
|
||||
public:
|
||||
@@ -66,16 +81,26 @@ namespace globebrowsing {
|
||||
T data;
|
||||
};
|
||||
|
||||
class LayerSettings {
|
||||
LayerSetting* setting(int i) { return layerSettings[i].get(); };
|
||||
private:
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
struct Layer {
|
||||
|
||||
|
||||
|
||||
std::string name;
|
||||
std::shared_ptr<TileProvider> tileProvider;
|
||||
bool isActive;
|
||||
|
||||
ChunkTilePile getChunkTilePile(const TileIndex& tileIndex, int pileSize) const;
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<LayerSetting>> layerSettings;
|
||||
|
||||
PerLayerSettings settings;
|
||||
std::vector<ILayerSetting*> isettings;
|
||||
|
||||
ChunkTilePile getChunkTilePile(const TileIndex& tileIndex, int pileSize) const;
|
||||
};
|
||||
|
||||
struct LayerGroup {
|
||||
|
||||
Reference in New Issue
Block a user