浏览代码

Tiny changes, removed some non relevant lines

Marko Pintera 13 年之前
父节点
当前提交
1fa581e378

+ 1 - 4
CamelotD3D11RenderSystem/Source/CmD3D11Mappings.cpp

@@ -101,7 +101,7 @@ namespace CamelotEngine
 				return D3D11_CULL_FRONT;
 			else
 				return D3D11_CULL_BACK;
-		case CULL_ANTICLOCKWISE:
+		case CULL_COUNTERCLOCKWISE:
 			if( flip )
 				return D3D11_CULL_BACK;
 			else
@@ -114,9 +114,6 @@ namespace CamelotEngine
 	{
 		switch(level)
 		{
-		case PM_POINTS:
-			LOGWRN("Point rendering not supported in DX11. You must utilize custom geometry shader for that feature");
-			return D3D11_FILL_SOLID; 
 		case PM_WIREFRAME:
 			return D3D11_FILL_WIREFRAME;
 		case PM_SOLID:

+ 1 - 3
CamelotD3D9Renderer/Source/CmD3D9Mappings.cpp

@@ -134,7 +134,7 @@ namespace CamelotEngine
 				return D3DCULL_CCW;
 			else
 				return D3DCULL_CW;
-		case CULL_ANTICLOCKWISE:
+		case CULL_COUNTERCLOCKWISE:
 			if( flip )
 				return D3DCULL_CW;
 			else
@@ -147,8 +147,6 @@ namespace CamelotEngine
 	{
 		switch(level)
 		{
-		case PM_POINTS:
-			return D3DFILL_POINT;
 		case PM_WIREFRAME:
 			return D3DFILL_WIREFRAME;
 		case PM_SOLID:

+ 2 - 0
CamelotFreeImgImporter/Include/CmFreeImgImporter.h

@@ -1,3 +1,5 @@
+#pragma once
+
 #include "CmFreeImgPrerequisites.h"
 #include "CmSpecificImporter.h"
 #include "CmImporter.h"

+ 1 - 4
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -1047,7 +1047,7 @@ namespace CamelotEngine
 				cullMode = GL_BACK;
 			}
 			break;
-		case CULL_ANTICLOCKWISE:
+		case CULL_COUNTERCLOCKWISE:
 			if (mActiveRenderTarget && 
 				((mActiveRenderTarget->requiresTextureFlipping() && !mInvertVertexWinding) ||
 				(!mActiveRenderTarget->requiresTextureFlipping() && mInvertVertexWinding)))
@@ -1130,9 +1130,6 @@ namespace CamelotEngine
 		GLenum glmode;
 		switch(level)
 		{
-		case PM_POINTS:
-			glmode = GL_POINT;
-			break;
 		case PM_WIREFRAME:
 			glmode = GL_LINE;
 			break;

+ 2 - 0
CamelotRenderer/CamelotRenderer.vcxproj

@@ -204,6 +204,7 @@
     <ClInclude Include="Include\CmIndexBuffer.h" />
     <ClInclude Include="Include\CmOcclusionQuery.h" />
     <ClInclude Include="Include\CmPixelBuffer.h" />
+    <ClInclude Include="Include\CmRasterizerStateImporter.h" />
     <ClInclude Include="Include\CmTextureView.h" />
     <ClInclude Include="Include\CmVertexBuffer.h" />
     <ClInclude Include="Include\CmHighLevelGpuProgram.h" />
@@ -291,6 +292,7 @@
     <ClCompile Include="Source\CmIndexData.cpp" />
     <ClCompile Include="Source\CmOcclusionQuery.cpp" />
     <ClCompile Include="Source\CmPixelBuffer.cpp" />
+    <ClCompile Include="Source\CmRasterizerStateImporter.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
     <ClCompile Include="Source\CmVertexBuffer.cpp" />
     <ClCompile Include="Source\CmHighLevelGpuProgram.cpp" />

+ 6 - 0
CamelotRenderer/CamelotRenderer.vcxproj.filters

@@ -365,6 +365,9 @@
     <ClInclude Include="Include\CmVertexData.h">
       <Filter>Header Files\RenderSystem</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmRasterizerStateImporter.h">
+      <Filter>Header Files\Importer</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CamelotRenderer.cpp">
@@ -553,5 +556,8 @@
     <ClCompile Include="Source\CmVertexData.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmRasterizerStateImporter.cpp">
+      <Filter>Source Files\Importer</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 3 - 5
CamelotRenderer/Include/CmCommonEnums.h

@@ -161,18 +161,16 @@ namespace CamelotEngine {
         /// Hardware culls triangles whose vertices are listed clockwise in the view (default).
         CULL_CLOCKWISE = 2,
         /// Hardware culls triangles whose vertices are listed anticlockwise in the view.
-        CULL_ANTICLOCKWISE = 3
+        CULL_COUNTERCLOCKWISE = 3
     };
 
     /** The polygon mode to use when rasterising. */
     enum PolygonMode
     {
-		/// Only points are rendered.
-        PM_POINTS = 1,
 		/// Wireframe models are rendered.
-        PM_WIREFRAME = 2,
+        PM_WIREFRAME = 1,
 		/// Solid polygons are rendered.
-        PM_SOLID = 3
+        PM_SOLID = 2
     };
 
     /** Defines the frame buffer types. */

+ 3 - 0
CamelotRenderer/Include/CmPrerequisites.h

@@ -249,6 +249,9 @@ namespace CamelotEngine
 	typedef ResourceHandle<GpuProgram> GpuProgramHandle;
 	typedef ResourceHandle<HighLevelGpuProgram> HighLevelGpuProgramHandle;
 	typedef ResourceHandle<Material> MaterialHandle;
+	typedef ResourceHandle<RasterizerState> RasterizerStateHandle;
+	typedef ResourceHandle<DepthStencilState> DepthStencilStateHandle;
+	typedef ResourceHandle<BlendState> BlendStateHandle;
 }
 
 #endif

+ 2 - 2
CamelotRenderer/Include/CmRasterizerState.h

@@ -2,7 +2,7 @@
 
 #include "CmPrerequisites.h"
 #include "CmCommonEnums.h"
-#include "CmIReflectable.h"
+#include "CmResource.h"
 
 namespace CamelotEngine
 {
@@ -34,7 +34,7 @@ namespace CamelotEngine
 	};
 
 	// TODO Low priority - Write doc explaining various states
-	class CM_EXPORT RasterizerState : public IReflectable
+	class CM_EXPORT RasterizerState : public Resource
 	{
 	public:
 		virtual ~RasterizerState() {}

+ 29 - 0
CamelotRenderer/Include/CmRasterizerStateImporter.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmSpecificImporter.h"
+#include "CmImporter.h"
+
+namespace CamelotEngine
+{
+	class RasterizerStateImporter : public SpecificImporter
+	{
+	public:
+		RasterizerStateImporter();
+		virtual ~RasterizerStateImporter();
+
+		/** Inherited from SpecificImporter */
+		virtual bool isExtensionSupported(const String& ext) const;
+
+		/** Inherited from SpecificImporter */
+		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
+
+		/** Inherited from SpecificImporter */
+		virtual BaseResourceHandle import(const String& filePath);
+	private:
+		vector<String>::type mExtensions;
+		std::unordered_map<String, int> mExtensionToFID;
+
+		String magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const;
+	};
+}

+ 0 - 2
CamelotRenderer/Include/CmResource.h

@@ -15,8 +15,6 @@ namespace CamelotEngine
 		Resource();
 		virtual ~Resource() {};
 
-
-
 		const String& getUUID() const { return mUUID; }
 
 		/**

+ 4 - 1
CamelotRenderer/Source/CmImporter.cpp

@@ -5,12 +5,15 @@
 #include "CmSpecificImporter.h"
 #include "CmDebug.h"
 #include "CmDataStream.h"
+#include "CmRasterizerStateImporter.h"
 #include "CmException.h"
 
 namespace CamelotEngine
 {
 	Importer::Importer()
-	{ }
+	{
+		registerAssetImporter(new RasterizerStateImporter());
+	}
 
 	Importer::~Importer()
 	{

+ 3 - 0
CamelotRenderer/Source/CmRasterizerState.cpp

@@ -1,5 +1,6 @@
 #include "CmRasterizerState.h"
 #include "CmRenderStateManager.h"
+#include "CmRenderSystem.h"
 #include "CmRasterizerStateRTTI.h"
 
 namespace CamelotEngine
@@ -7,6 +8,8 @@ namespace CamelotEngine
 	void RasterizerState::initialize(const RASTERIZER_STATE_DESC& desc)
 	{
 		mData = desc;
+
+		RenderSystem::instancePtr()->queueCommand(boost::bind(&RasterizerState::initialize_internal, this));
 	}
 
 	const RasterizerStatePtr& RasterizerState::getDefault()

+ 61 - 0
CamelotRenderer/Source/CmRasterizerStateImporter.cpp

@@ -0,0 +1,61 @@
+#include "CmRasterizerStateImporter.h"
+#include "CmResource.h"
+#include "CmDebug.h"
+#include "CmDataStream.h"
+#include "CmPath.h"
+#include "CmFileSystem.h"
+#include "CmRasterizerState.h"
+
+namespace CamelotEngine
+{
+	RasterizerStateImporter::RasterizerStateImporter()
+		:SpecificImporter() 
+	{
+
+	}
+
+	RasterizerStateImporter::~RasterizerStateImporter() 
+	{
+
+	}
+
+	bool RasterizerStateImporter::isExtensionSupported(const String& ext) const
+	{
+		String lowerCaseExt = ext;
+		StringUtil::toLowerCase(lowerCaseExt);
+
+		return find(mExtensions.begin(), mExtensions.end(), lowerCaseExt) != mExtensions.end();
+	}
+
+	bool RasterizerStateImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const
+	{
+		String ext = magicNumToExtension(magicNumPtr, numBytes);
+
+		return isExtensionSupported(ext);
+	}
+
+	String RasterizerStateImporter::magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const
+	{
+		return StringUtil::BLANK;
+	}
+
+	BaseResourceHandle RasterizerStateImporter::import(const String& filePath)
+	{
+		DataStreamPtr fileData = FileSystem::open(filePath, true);
+
+		RASTERIZER_STATE_DESC stateDesc;// = parseStateData(fileData);
+
+
+		// TODO - Not initialized properly
+
+
+		RasterizerStateHandle newState(RasterizerState::create(stateDesc));
+
+		newState.waitUntilLoaded();
+		fileData->close();
+
+		registerLoadedResource(newState);
+
+		return newState;
+	}
+}

+ 48 - 26
CamelotRenderer/TODO.txt

@@ -31,18 +31,53 @@ And Resources.DestroyUnusedAssets destroys all with just 1 reference?
 
 Resource::destroy_internal is not abstract temporarily so I can test
 
-Shader parser (possible leave for later? But it might require Resource changes)
- - Static/Dynamic usage for GpuParamBlocks
- - Ability to mark param blocks as "Shared". Those would not get created with every pass instance and would require user to actually create and assign them
-   - I can't think of any way I can do this without a preprocessor
-   - (In editor it might work via GUI, but what if someone doesn't want to use the editor and only uses the engine core?)
-   - Use a simple .shader file in which you specify individual GPU programs, include files, material parameters (whether they're visible
-     to user or just rendering system), input parameters (useful for GLSL which doesn't have semantics as I can provide my own semantics)
-	  - File format would be simple, and parser would just parse line by line, with possible option blocks
-   - Issue of include files remains. How do I reference them? By path most definitely but I'd have to reference the source asset path...And in the current design source asset can move.
-   - Smart way of initializing GpuParamBlocks (without duplicates) (This probably won't be a separate task, as user will specify params manually if I go the parser route)
-   - Make sure that gpu programs assigned to Pass don't share parameters of different types (A task I can ignore if I go the parser route)
- 
+Stuff that needs destroy():
+ - GpuProgram (DONE)
+ - HighLevelGpuProgram (DONE)
+ - Texture (DONE)
+ - Mesh
+ - VertexBuffer
+ - IndexBuffer
+ - GpuBuffer
+ - VertexDeclaration
+ - RenderWindow
+ - Blend/DepthStencil/Rasterizer/SamplerState
+ - GpuParamBlock
+---
+ Maybe
+  - Material
+  - Pass
+  - Shader
+  - Technique
+
+
+Add support for include file resource
+Make sure we can add an include file to a HighLevelGpuProgram, and make sure it uses it
+ - Also a way to list all referenced includes, and a way to remove them
+
+Make Raster/DepthStencil/Blend/Sampler states resources
+Make Shader a resource
+
+Make GpuParamBlock a resource
+ - Static/Dynamic usage for GpuParamBlock
+ - rename current GpuParamBlock into GpuParamBlockBuffer
+ - add new class GpuParamBlock that has addParameter(name, gpuProgramVariable, type, visible)
+ - it stores data on per-parameter basis
+ - it is a Resource and is serializable
+ - in Material when an actual technique is chosen, GpuParamBlockBuffer is bound to GpuParamBlock
+
+Shader::addParamBlock(name, GPU_PARAM_BLOCK_DESC, bool shared)
+ - If its shared it won't be instantiated manually when material chooses an actual technique
+ - When this method is called we check if any parameter rules are broken:
+   - Ignore missing variables from a param block (weaker techniques might not need them all)
+   - Throw an error if the specified variables come from two different param blocks
+   - Global block should be special to accomodate DX9 shaders
+Shader::addParameter(name, gpuVariableName, type, visible) - Only for objects like textures/buffers/samplers
+
+Material::setParameter - does what it did so far
+Material::setSharedGpuParamBlock(name, GpuParamBlock) - makes he specified block share the data
+
+
  Refactor how we handle RenderTargets (no attach/detach, and no waitForVSync propery in RenderSystem)
  waitForVsync can probably be moved somewhere other than being directly in RenderSystem? (where is it in DX11?)
 
@@ -54,25 +89,12 @@ Can be delayed:
  Better creation of PrimaryWindow
   - RENDERWINDOWDESC accepts a "externalWindow" flag and an "externalHandle" so when creating the primary window with RenderSystem::initialize we don't always need to create a new window
   - Actually new OpenGL seems to support creating context without a window with the help of wglCreateContextAttribsARB and wglMakeCurrent:
-
+ ImportOptions
 >>>>>>>>>>>>>>>START WORKING ON THE EDITOR!
  
 
 ---------------------------------------------------
 
-<<<<Resource destruction:>>>
- Each resource has isDestroyed flag. It is set to true when the user calls destroy(). Destroy will unload all heavyweight underlying data but won't destroy the actual pointer. 
- If a destructor is called without having first called destroy() an error is logged that the resource wasn't freed properly.
- Destroy requests will always get queued up at the end of the frame, so that if render system is still using those resources, it has access to them
-   - But then when and how do I actually delete the resource?
-   - Also queued up? OR I don't destroy it?
-   - All internal resources are handled via SharedPtrs so the lightweight reference only gets removed after all actual references are gone.
- For example unloading a texture:
-  - Call texture.destroy()
-    - Removes the texture from Resources and any other place that holds a known reference
-    - Actually destroys the resource and sets isDestroyed flag to true
-    - Reference to the empty texture continues to exist but render system need to check if its destroyed before it tries to use it
-
 <<<<Handle multithreaded object management>>>:
  - Make everything that is possible immutable. Once created it cant be changed.
   - Example are shaders, state objects and similar

+ 1 - 1
CamelotUtility/Include/CmString.h

@@ -318,7 +318,7 @@ namespace CamelotEngine {
     @returns
         0.0 if the value could not be parsed, otherwise the float version of the String.
     */
-    CM_UTILITY_EXPORT float parseReal(const String& val, float defaultValue = 0);
+    CM_UTILITY_EXPORT float parseFloat(const String& val, float defaultValue = 0);
     /** Converts a String to a whole number. 
     @returns
         0.0 if the value could not be parsed, otherwise the numeric version of the String.

+ 1 - 1
CamelotUtility/Source/CmString.cpp

@@ -610,7 +610,7 @@ namespace CamelotEngine {
 		return stream.str();
 	}
 	//-----------------------------------------------------------------------
-	float parseReal(const String& val, float defaultValue)
+	float parseFloat(const String& val, float defaultValue)
 	{
 		// Use istringstream for direct correspondence with toString
 		StringStream str(val);