Browse Source

Determining struct stride a bit better

Marko Pintera 13 years ago
parent
commit
f7fc8e84ca

+ 0 - 2
CamelotD3D11RenderSystem/Source/CmD3D11HLSLParamParser.cpp

@@ -210,8 +210,6 @@ namespace CamelotEngine
 				" and DirectX size is: " + toString(blockDesc.blockSize * 4));
 				" and DirectX size is: " + toString(blockDesc.blockSize * 4));
 		}
 		}
 #endif
 #endif
-
-		//blockDesc.blockSize = constantBufferDesc.Size / 4; 
 	}
 	}
 
 
 	void D3D11HLSLParamParser::parseVariable(D3D11_SHADER_TYPE_DESC& varTypeDesc, D3D11_SHADER_VARIABLE_DESC& varDesc, GpuParamDesc& desc, GpuParamBlockDesc& paramBlock)
 	void D3D11HLSLParamParser::parseVariable(D3D11_SHADER_TYPE_DESC& varTypeDesc, D3D11_SHADER_VARIABLE_DESC& varDesc, GpuParamDesc& desc, GpuParamBlockDesc& paramBlock)

+ 10 - 3
CamelotGLRenderer/Source/GLSL/include/CmGLSLParamParser.h

@@ -366,14 +366,21 @@ namespace CamelotEngine
 
 
 				// Update struct with size of the new parameter
 				// Update struct with size of the new parameter
 				GpuParamDataDesc& structDesc = foundStructs[structName];
 				GpuParamDataDesc& structDesc = foundStructs[structName];
-				structDesc.arraySize = std::max(structDesc.arraySize, arrayIdx + 1);
-
+				
 				assert(gpuParam.cpuMemOffset >= structDesc.cpuMemOffset);
 				assert(gpuParam.cpuMemOffset >= structDesc.cpuMemOffset);
 				if(arrayIdx == 0)
 				if(arrayIdx == 0)
 				{
 				{
 					structDesc.elementSize = std::max(structDesc.elementSize, (gpuParam.cpuMemOffset - structDesc.cpuMemOffset) + gpuParam.arrayElementStride * gpuParam.arraySize);
 					structDesc.elementSize = std::max(structDesc.elementSize, (gpuParam.cpuMemOffset - structDesc.cpuMemOffset) + gpuParam.arrayElementStride * gpuParam.arraySize);
-					structDesc.arrayElementStride = structDesc.elementSize; // TODO - Possibly aligned to 64 byte boundary?
+					structDesc.arrayElementStride = structDesc.elementSize;
 				}
 				}
+
+				// New array element reached, determine arrayElementStride
+				if(arrayIdx > 0 && structDesc.arraySize == 1)
+				{
+					structDesc.arrayElementStride = gpuParam.cpuMemOffset - structDesc.cpuMemOffset; 
+				}
+
+				structDesc.arraySize = std::max(structDesc.arraySize, arrayIdx + 1);
 			}
 			}
 		}
 		}
 
 

+ 0 - 1
TODODoc.txt

@@ -9,6 +9,5 @@
      - packoffset on parameters is not supported and will likely result in invalid constant buffer size and/or element offsets
      - packoffset on parameters is not supported and will likely result in invalid constant buffer size and/or element offsets
   - GLSL limitations
   - GLSL limitations
      - layout(row_major) is not supported and will likely result in incorrect matrices
      - layout(row_major) is not supported and will likely result in incorrect matrices
-	 - Only std140 packing method is supported, others will likely result in invalid constant buffer size and/or element offsets
   - Texture limitations: Only 1D, 2D, 3D and Cube textures (and their samplers) are supported. Support for multisampled textures
   - Texture limitations: Only 1D, 2D, 3D and Cube textures (and their samplers) are supported. Support for multisampled textures
      is included where necessary to implement render targets. Support for texture arrays and is not included.
      is included where necessary to implement render targets. Support for texture arrays and is not included.