Переглянути джерело

GetBufferHash(): signed index, style

1vanK 3 роки тому
батько
коміт
755f34c019

+ 4 - 4
Source/Urho3D/AngelScript/Generated_Members.h

@@ -9886,8 +9886,8 @@ template <class T> void RegisterMembers_Geometry(asIScriptEngine* engine, const
     // void Geometry::Draw(Graphics* graphics)
     // void Geometry::Draw(Graphics* graphics)
     engine->RegisterObjectMethod(className, "void Draw(Graphics@+)", AS_METHODPR(T, Draw, (Graphics*), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Draw(Graphics@+)", AS_METHODPR(T, Draw, (Graphics*), void), AS_CALL_THISCALL);
 
 
-    // unsigned short Geometry::GetBufferHash() const
-    engine->RegisterObjectMethod(className, "uint16 GetBufferHash() const", AS_METHODPR(T, GetBufferHash, () const, unsigned short), AS_CALL_THISCALL);
+    // u16 Geometry::GetBufferHash() const
+    engine->RegisterObjectMethod(className, "uint16 GetBufferHash() const", AS_METHODPR(T, GetBufferHash, () const, u16), AS_CALL_THISCALL);
 
 
     // IndexBuffer* Geometry::GetIndexBuffer() const
     // IndexBuffer* Geometry::GetIndexBuffer() const
     engine->RegisterObjectMethod(className, "IndexBuffer@+ GetIndexBuffer() const", AS_METHODPR(T, GetIndexBuffer, () const, IndexBuffer*), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "IndexBuffer@+ GetIndexBuffer() const", AS_METHODPR(T, GetIndexBuffer, () const, IndexBuffer*), AS_CALL_THISCALL);
@@ -12453,8 +12453,8 @@ template <class T> void RegisterMembers_VertexBuffer(asIScriptEngine* engine, co
     // bool VertexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false)
     // bool VertexBuffer::SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false)
     // Error: type "const void*" can not automatically bind
     // Error: type "const void*" can not automatically bind
 
 
-    // unsigned long long VertexBuffer::GetBufferHash(unsigned streamIndex)
-    engine->RegisterObjectMethod(className, "uint64 GetBufferHash(uint)", AS_METHODPR(T, GetBufferHash, (unsigned), unsigned long long), AS_CALL_THISCALL);
+    // u64 VertexBuffer::GetBufferHash(i32 streamIndex)
+    engine->RegisterObjectMethod(className, "uint64 GetBufferHash(int)", AS_METHODPR(T, GetBufferHash, (i32), u64), AS_CALL_THISCALL);
 
 
     // VertexMaskFlags VertexBuffer::GetElementMask() const
     // VertexMaskFlags VertexBuffer::GetElementMask() const
     engine->RegisterObjectMethod(className, "VertexMaskFlags GetElementMask() const", AS_METHODPR(T, GetElementMask, () const, VertexMaskFlags), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "VertexMaskFlags GetElementMask() const", AS_METHODPR(T, GetElementMask, () const, VertexMaskFlags), AS_CALL_THISCALL);

+ 5 - 5
Source/Urho3D/Graphics/Geometry.cpp

@@ -174,18 +174,18 @@ VertexBuffer* Geometry::GetVertexBuffer(unsigned index) const
     return index < vertexBuffers_.Size() ? vertexBuffers_[index] : nullptr;
     return index < vertexBuffers_.Size() ? vertexBuffers_[index] : nullptr;
 }
 }
 
 
-unsigned short Geometry::GetBufferHash() const
+u16 Geometry::GetBufferHash() const
 {
 {
-    unsigned short hash = 0;
+    u16 hash = 0;
 
 
-    for (unsigned i = 0; i < vertexBuffers_.Size(); ++i)
+    for (i32 i = 0; i < vertexBuffers_.Size(); ++i)
     {
     {
         VertexBuffer* vBuf = vertexBuffers_[i];
         VertexBuffer* vBuf = vertexBuffers_[i];
-        hash += *((unsigned short*)&vBuf);
+        hash += *((u16*)&vBuf);
     }
     }
 
 
     IndexBuffer* iBuf = indexBuffer_;
     IndexBuffer* iBuf = indexBuffer_;
-    hash += *((unsigned short*)&iBuf);
+    hash += *((u16*)&iBuf);
 
 
     return hash;
     return hash;
 }
 }

+ 1 - 1
Source/Urho3D/Graphics/Geometry.h

@@ -91,7 +91,7 @@ public:
     float GetLodDistance() const { return lodDistance_; }
     float GetLodDistance() const { return lodDistance_; }
 
 
     /// Return buffers' combined hash value for state sorting.
     /// Return buffers' combined hash value for state sorting.
-    unsigned short GetBufferHash() const;
+    u16 GetBufferHash() const;
     /// Return raw vertex and index data for CPU operations, or null pointers if not available. Will return data of the first vertex buffer if override data not set.
     /// Return raw vertex and index data for CPU operations, or null pointers if not available. Will return data of the first vertex buffer if override data not set.
     void GetRawData(const unsigned char*& vertexData, unsigned& vertexSize, const unsigned char*& indexData, unsigned& indexSize, const Vector<VertexElement>*& elements) const;
     void GetRawData(const unsigned char*& vertexData, unsigned& vertexSize, const unsigned char*& indexData, unsigned& indexSize, const Vector<VertexElement>*& elements) const;
     /// Return raw vertex and index data for CPU operations, or null pointers if not available. Will return data of the first vertex buffer if override data not set.
     /// Return raw vertex and index data for CPU operations, or null pointers if not available. Will return data of the first vertex buffer if override data not set.

+ 2 - 2
Source/Urho3D/GraphicsAPI/Direct3D11/D3D11Graphics.cpp

@@ -2430,8 +2430,8 @@ void Graphics::PrepareDraw_D3D11()
             impl->firstDirtyVB_ = impl->lastDirtyVB_ = M_MAX_UNSIGNED;
             impl->firstDirtyVB_ = impl->lastDirtyVB_ = M_MAX_UNSIGNED;
         }
         }
 
 
-        unsigned long long newVertexDeclarationHash = 0;
-        for (unsigned i = 0; i < MAX_VERTEX_STREAMS; ++i)
+        u64 newVertexDeclarationHash = 0;
+        for (i32 i = 0; i < MAX_VERTEX_STREAMS; ++i)
         {
         {
             if (vertexBuffers_[i])
             if (vertexBuffers_[i])
                 newVertexDeclarationHash |= vertexBuffers_[i]->GetBufferHash(i);
                 newVertexDeclarationHash |= vertexBuffers_[i]->GetBufferHash(i);

+ 2 - 2
Source/Urho3D/GraphicsAPI/Direct3D9/D3D9Graphics.cpp

@@ -961,8 +961,8 @@ bool Graphics::SetVertexBuffers_D3D9(const Vector<VertexBuffer*>& buffers, unsig
     }
     }
 
 
     // Build vertex declaration hash code out of the buffers
     // Build vertex declaration hash code out of the buffers
-    unsigned long long hash = 0;
-    for (unsigned i = 0; i < buffers.Size(); ++i)
+    u64 hash = 0;
+    for (i32 i = 0; i < buffers.Size(); ++i)
     {
     {
         if (!buffers[i])
         if (!buffers[i])
             continue;
             continue;

+ 1 - 1
Source/Urho3D/GraphicsAPI/VertexBuffer.h

@@ -115,7 +115,7 @@ public:
     SharedArrayPtr<u8> GetShadowDataShared() const { return shadowData_; }
     SharedArrayPtr<u8> GetShadowDataShared() const { return shadowData_; }
 
 
     /// Return buffer hash for building vertex declarations. Used internally.
     /// Return buffer hash for building vertex declarations. Used internally.
-    unsigned long long GetBufferHash(unsigned streamIndex) { return elementHash_ << (streamIndex * 16); }
+    u64 GetBufferHash(i32 streamIndex) { return elementHash_ << (streamIndex * 16); }
 
 
     /// Return element with specified type and semantic from a vertex element list, or null if does not exist.
     /// Return element with specified type and semantic from a vertex element list, or null if does not exist.
     static const VertexElement* GetElement(const Vector<VertexElement>& elements, VertexElementType type, VertexElementSemantic semantic, i8 index = 0);
     static const VertexElement* GetElement(const Vector<VertexElement>& elements, VertexElementType type, VertexElementSemantic semantic, i8 index = 0);