Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 1 file). Show all
Unified · Split
| @@ -122,6 +122,9 @@ static const gpu::Element TEXCOORD4_ELEMENT { gpu::VEC4, gpu::FLOAT, gpu::XYZW } · 121 unmodified lines | |||
| 122 | static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT; | 122 | static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT; |
| 123 | static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT; | 123 | static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT; |
| 124 | static gpu::Stream::FormatPointer INSTANCED_SOLID_FADE_STREAM_FORMAT; | 124 | static gpu::Stream::FormatPointer INSTANCED_SOLID_FADE_STREAM_FORMAT; |
| 125 | static gpu::Stream::FormatPointer WIRE_STREAM_FORMAT; | ||
| 126 | static gpu::Stream::FormatPointer INSTANCED_WIRE_STREAM_FORMAT; | ||
| 127 | static gpu::Stream::FormatPointer INSTANCED_WIRE_FADE_STREAM_FORMAT; | ||
| 125 | 128 | ||
| 126 | static const uint SHAPE_VERTEX_STRIDE = sizeof(GeometryCache::ShapeVertex); // position, normal, texcoords, tangent | 129 | static const uint SHAPE_VERTEX_STRIDE = sizeof(GeometryCache::ShapeVertex); // position, normal, texcoords, tangent |
| 127 | static const uint SHAPE_NORMALS_OFFSET = offsetof(GeometryCache::ShapeVertex, normal); | 130 | static const uint SHAPE_NORMALS_OFFSET = offsetof(GeometryCache::ShapeVertex, normal); |
| @@ -690,6 +693,38 @@ gpu::Stream::FormatPointer& getInstancedSolidFadeStreamFormat() { · 562 unmodified lines | |||
| 690 | return INSTANCED_SOLID_FADE_STREAM_FORMAT; | 693 | return INSTANCED_SOLID_FADE_STREAM_FORMAT; |
| 691 | } | 694 | } |
| 692 | 695 | ||
| 696 | gpu::Stream::FormatPointer& getWireStreamFormat() { | ||
| 697 | if (!WIRE_STREAM_FORMAT) { | ||
| 698 | WIRE_STREAM_FORMAT = std::make_shared<gpu::Stream::Format>(); // 1 for everyone | ||
| 699 | WIRE_STREAM_FORMAT->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, POSITION_ELEMENT); | ||
| 700 | WIRE_STREAM_FORMAT->setAttribute(gpu::Stream::NORMAL, gpu::Stream::NORMAL, NORMAL_ELEMENT); | ||
| 701 | } | ||
| 702 | return WIRE_STREAM_FORMAT; | ||
| 703 | } | ||
| 704 | |||
| 705 | gpu::Stream::FormatPointer& getInstancedWireStreamFormat() { | ||
| 706 | if (!INSTANCED_WIRE_STREAM_FORMAT) { | ||
| 707 | INSTANCED_WIRE_STREAM_FORMAT = std::make_shared<gpu::Stream::Format>(); // 1 for everyone | ||
| 708 | INSTANCED_WIRE_STREAM_FORMAT->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, POSITION_ELEMENT); | ||
| 709 | INSTANCED_WIRE_STREAM_FORMAT->setAttribute(gpu::Stream::NORMAL, gpu::Stream::NORMAL, NORMAL_ELEMENT); | ||
| 710 | INSTANCED_WIRE_STREAM_FORMAT->setAttribute(gpu::Stream::COLOR, gpu::Stream::COLOR, COLOR_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 711 | } | ||
| 712 | return INSTANCED_WIRE_STREAM_FORMAT; | ||
| 713 | } | ||
| 714 | |||
| 715 | gpu::Stream::FormatPointer& getInstancedWireFadeStreamFormat() { | ||
| 716 | if (!INSTANCED_WIRE_FADE_STREAM_FORMAT) { | ||
| 717 | INSTANCED_WIRE_FADE_STREAM_FORMAT = std::make_shared<gpu::Stream::Format>(); // 1 for everyone | ||
| 718 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, POSITION_ELEMENT); | ||
| 719 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::NORMAL, gpu::Stream::NORMAL, NORMAL_ELEMENT); | ||
| 720 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::COLOR, gpu::Stream::COLOR, COLOR_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 721 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::TEXCOORD2, gpu::Stream::TEXCOORD2, TEXCOORD4_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 722 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::TEXCOORD3, gpu::Stream::TEXCOORD3, TEXCOORD4_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 723 | INSTANCED_WIRE_FADE_STREAM_FORMAT->setAttribute(gpu::Stream::TEXCOORD4, gpu::Stream::TEXCOORD4, TEXCOORD4_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 724 | } | ||
| 725 | return INSTANCED_WIRE_FADE_STREAM_FORMAT; | ||
| 726 | } | ||
| 727 | |||
| 693 | QHash<SimpleProgramKey, gpu::PipelinePointer> GeometryCache::_simplePrograms; | 728 | QHash<SimpleProgramKey, gpu::PipelinePointer> GeometryCache::_simplePrograms; |
| 694 | 729 | ||
| 695 | gpu::ShaderPointer GeometryCache::_simpleShader; | 730 | gpu::ShaderPointer GeometryCache::_simpleShader; |
| @@ -827,7 +862,7 @@ void GeometryCache::renderShape(gpu::Batch& batch, Shape shape) { · 131 unmodified lines | |||
| 827 | } | 862 | } |
| 828 | 863 | ||
| 829 | void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape) { | 864 | void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape) { |
| 830 | batch.setInputFormat(getSolidStreamFormat()); | 865 | batch.setInputFormat(getWireStreamFormat()); |
| 831 | _shapes[shape].drawWire(batch); | 866 | _shapes[shape].drawWire(batch); |
| 832 | } | 867 | } |
| 833 | 868 | ||
| @@ -839,7 +874,7 @@ void GeometryCache::renderShape(gpu::Batch& batch, Shape shape, const glm::vec4& · 5 unmodified lines | |||
| 839 | } | 874 | } |
| 840 | 875 | ||
| 841 | void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape, const glm::vec4& color) { | 876 | void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape, const glm::vec4& color) { |
| 842 | batch.setInputFormat(getSolidStreamFormat()); | 877 | batch.setInputFormat(getWireStreamFormat()); |
| 843 | // Color must be set after input format | 878 | // Color must be set after input format |
| 844 | batch._glColor4f(color.r, color.g, color.b, color.a); | 879 | batch._glColor4f(color.r, color.g, color.b, color.a); |
| 845 | _shapes[shape].drawWire(batch); | 880 | _shapes[shape].drawWire(batch); |
| @@ -857,7 +892,7 @@ void GeometryCache::renderShapeInstances(gpu::Batch& batch, Shape shape, size_t · 11 unmodified lines | |||
| 857 | } | 892 | } |
| 858 | 893 | ||
| 859 | void GeometryCache::renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer) { | 894 | void GeometryCache::renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer) { |
| 860 | batch.setInputFormat(getInstancedSolidStreamFormat()); | 895 | batch.setInputFormat(getInstancedWireStreamFormat()); |
| 861 | setupBatchInstance(batch, colorBuffer); | 896 | setupBatchInstance(batch, colorBuffer); |
| 862 | _shapes[shape].drawWireInstances(batch, count); | 897 | _shapes[shape].drawWireInstances(batch, count); |
| 863 | } | 898 | } |
| @@ -883,7 +918,7 @@ void GeometryCache::renderFadeShapeInstances(gpu::Batch& batch, Shape shape, siz · 19 unmodified lines | |||
| 883 | 918 | ||
| 884 | void GeometryCache::renderWireFadeShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer, | 919 | void GeometryCache::renderWireFadeShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& colorBuffer, |
| 885 | gpu::BufferPointer& fadeBuffer1, gpu::BufferPointer& fadeBuffer2, gpu::BufferPointer& fadeBuffer3) { | 920 | gpu::BufferPointer& fadeBuffer1, gpu::BufferPointer& fadeBuffer2, gpu::BufferPointer& fadeBuffer3) { |
| 886 | batch.setInputFormat(getInstancedSolidFadeStreamFormat()); | 921 | batch.setInputFormat(getInstancedWireFadeStreamFormat()); |
| 887 | setupBatchFadeInstance(batch, colorBuffer, fadeBuffer1, fadeBuffer2, fadeBuffer3); | 922 | setupBatchFadeInstance(batch, colorBuffer, fadeBuffer1, fadeBuffer2, fadeBuffer3); |
| 888 | _shapes[shape].drawWireInstances(batch, count); | 923 | _shapes[shape].drawWireInstances(batch, count); |
| 889 | } | 924 | } |