Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 50 files). Show all
Unified · Split
| @@ -722,42 +722,12 @@ gpu::ShaderPointer GeometryCache::_forwardUnlitShader; · 721 unmodified lines | |||
| 722 | gpu::ShaderPointer GeometryCache::_forwardSimpleFadeShader; | 722 | gpu::ShaderPointer GeometryCache::_forwardSimpleFadeShader; |
| 723 | gpu::ShaderPointer GeometryCache::_forwardUnlitFadeShader; | 723 | gpu::ShaderPointer GeometryCache::_forwardUnlitFadeShader; |
| 724 | 724 | ||
| 725 | render::ShapePipelinePointer GeometryCache::_simpleOpaquePipeline; | 725 | std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> GeometryCache::_shapePipelines; |
| 726 | render::ShapePipelinePointer GeometryCache::_simpleTransparentPipeline; | ||
| 727 | render::ShapePipelinePointer GeometryCache::_forwardSimpleOpaquePipeline; | ||
| 728 | render::ShapePipelinePointer GeometryCache::_forwardSimpleTransparentPipeline; | ||
| 729 | render::ShapePipelinePointer GeometryCache::_simpleOpaqueFadePipeline; | ||
| 730 | render::ShapePipelinePointer GeometryCache::_simpleTransparentFadePipeline; | ||
| 731 | render::ShapePipelinePointer GeometryCache::_simpleWirePipeline; | ||
| 732 | |||
| 733 | uint8_t GeometryCache::CUSTOM_PIPELINE_NUMBER = 0; | ||
| 734 | |||
| 735 | render::ShapePipelinePointer GeometryCache::shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) { | ||
| 736 | initializeShapePipelines(); | ||
| 737 | |||
| 738 | if (key.isWireframe()) { | ||
| 739 | return _simpleWirePipeline; | ||
| 740 | } | ||
| 741 | |||
| 742 | if (key.isFaded()) { | ||
| 743 | if (key.isTranslucent()) { | ||
| 744 | return _simpleTransparentFadePipeline; | ||
| 745 | } else { | ||
| 746 | return _simpleOpaqueFadePipeline; | ||
| 747 | } | ||
| 748 | } else { | ||
| 749 | if (key.isTranslucent()) { | ||
| 750 | return _simpleTransparentPipeline; | ||
| 751 | } else { | ||
| 752 | return _simpleOpaquePipeline; | ||
| 753 | } | ||
| 754 | } | ||
| 755 | } | ||
| 756 | 726 | ||
| 757 | GeometryCache::GeometryCache() : | 727 | GeometryCache::GeometryCache() : |
| 758 | _nextID(0) { | 728 | _nextID(0) { |
| 759 | // Let's register its special shapePipeline factory: | 729 | // Let's register its special shapePipeline factory: |
| 760 | registerShapePipeline(); | 730 | initializeShapePipelines(); |
| 761 | buildShapes(); | 731 | buildShapes(); |
| 762 | } | 732 | } |
| 763 | 733 | ||
| @@ -799,16 +769,14 @@ void GeometryCache::releaseID(int id) { · 35 unmodified lines | |||
| 799 | } | 769 | } |
| 800 | 770 | ||
| 801 | void GeometryCache::initializeShapePipelines() { | 771 | void GeometryCache::initializeShapePipelines() { |
| 802 | if (!_simpleOpaquePipeline) { | 772 | if (_shapePipelines.empty()) { |
| 803 | _simpleOpaquePipeline = getShapePipeline(false, false, true, false); | 773 | const int NUM_PIPELINES = 8; |
| 804 | _simpleTransparentPipeline = getShapePipeline(false, true, true, false); | 774 | for (int i = 0; i < NUM_PIPELINES; ++i) { |
| 805 | _forwardSimpleOpaquePipeline = getShapePipeline(false, false, true, false, false, true); | 775 | bool transparent = i & 1; |
| 806 | _forwardSimpleTransparentPipeline = getShapePipeline(false, true, true, false, false, true); | 776 | bool unlit = i & 2; |
| 807 | 777 | bool forward = i & 4; | |
| 808 | // FIXME: these need forward pipelines | 778 | _shapePipelines[std::make_tuple(transparent, unlit, forward)] = getShapePipeline(false, transparent, true, unlit, false, forward); |
| 809 | _simpleOpaqueFadePipeline = getFadingShapePipeline(false, false, false, false, false); | 779 | } |
| 810 | _simpleTransparentFadePipeline = getFadingShapePipeline(false, true, false, false, false); | ||
| 811 | _simpleWirePipeline = getShapePipeline(false, false, true, true); | ||
| 812 | } | 780 | } |
| 813 | } | 781 | } |
| 814 | 782 | ||
| @@ -1027,7 +995,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 212 unmodified lines | |||
| 1027 | int* colorData = new int[details.vertices]; | 995 | int* colorData = new int[details.vertices]; |
| 1028 | int* colorDataAt = colorData; | 996 | int* colorDataAt = colorData; |
| 1029 | 997 | ||
| 1030 | const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | 998 | const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); |
| 1031 | auto pointCount = points.size(); | 999 | auto pointCount = points.size(); |
| 1032 | auto colorCount = colors.size(); | 1000 | auto colorCount = colors.size(); |
| 1033 | int compactColor = 0; | 1001 | int compactColor = 0; |
| @@ -1105,7 +1073,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 71 unmodified lines | |||
| 1105 | int* colorData = new int[details.vertices]; | 1073 | int* colorData = new int[details.vertices]; |
| 1106 | int* colorDataAt = colorData; | 1074 | int* colorDataAt = colorData; |
| 1107 | 1075 | ||
| 1108 | const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | 1076 | const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); |
| 1109 | auto pointCount = points.size(); | 1077 | auto pointCount = points.size(); |
| 1110 | auto colorCount = colors.size(); | 1078 | auto colorCount = colors.size(); |
| 1111 | for (auto i = 0; i < pointCount; i++) { | 1079 | for (auto i = 0; i < pointCount; i++) { |
| @@ -1193,7 +1161,7 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 81 unmodified lines | |||
| 1193 | int* colorData = new int[details.vertices]; | 1161 | int* colorData = new int[details.vertices]; |
| 1194 | int* colorDataAt = colorData; | 1162 | int* colorDataAt = colorData; |
| 1195 | 1163 | ||
| 1196 | const glm::vec3 NORMAL(0.0f, 1.0f, 0.0f); | 1164 | const glm::vec3 NORMAL(0.0f, -1.0f, 0.0f); |
| 1197 | for (int i = 0; i < points.size(); i++) { | 1165 | for (int i = 0; i < points.size(); i++) { |
| 1198 | glm::vec3 point = points[i]; | 1166 | glm::vec3 point = points[i]; |
| 1199 | glm::vec2 texCoord = texCoords[i]; | 1167 | glm::vec2 texCoord = texCoords[i]; |
| @@ -2281,8 +2249,7 @@ void renderInstances(RenderArgs* args, gpu::Batch& batch, const glm::vec4& color · 1081 unmodified lines | |||
| 2281 | 2249 | ||
| 2282 | if (isWire) { | 2250 | if (isWire) { |
| 2283 | DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); | 2251 | DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); |
| 2284 | } | 2252 | } else { |
| 2285 | else { | ||
| 2286 | DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); | 2253 | DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), data.buffers[INSTANCE_COLOR_BUFFER]); |
| 2287 | } | 2254 | } |
| 2288 | }); | 2255 | }); |