diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 3b8c7a939e..95f4828ca1 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -521,7 +521,7 @@ void VertexDecoder::Step_NormalS8Skin() const void VertexDecoder::Step_NormalS16Skin() const { float *normal = (float *)(decoded_ + decFmt.nrmoff); - const s16 *sv = (const u16_le*)(ptr_ + nrmoff); + const s16 *sv = (const s16_le*)(ptr_ + nrmoff); const float fn[3] = { sv[0] * (1.0f / 32768.0f), sv[1] * (1.0f / 32768.0f), sv[2] * (1.0f / 32768.0f) }; Norm3ByMatrix43(normal, fn, skinMatrix); } diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index c6424071d4..8b82cb1e70 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -1536,10 +1536,13 @@ void DIRECTX9_GPU::ClearCacheNextFrame() { void DIRECTX9_GPU::Resized() { framebufferManager_.Resized(); + transformDraw_.Resized(); } + void DIRECTX9_GPU::ClearShaderCache() { shaderManager_->ClearCache(true); } + std::vector DIRECTX9_GPU::GetFramebufferList() { return framebufferManager_.GetFramebufferList(); } diff --git a/GPU/Directx9/TransformPipelineDX9.cpp b/GPU/Directx9/TransformPipelineDX9.cpp index 877c9667ee..416f3ecfc0 100644 --- a/GPU/Directx9/TransformPipelineDX9.cpp +++ b/GPU/Directx9/TransformPipelineDX9.cpp @@ -173,6 +173,9 @@ TransformDrawEngineDX9::TransformDrawEngineDX9() uvScale = new UVScale[MAX_DEFERRED_DRAW_CALLS]; } indexGen.Setup(decIndex); + + decJitCache_ = new VertexDecoderJitCache(); + InitDeviceObjects(); } @@ -195,6 +198,9 @@ TransformDrawEngineDX9::~TransformDrawEngineDX9() { delete iter->second; } delete [] uvScale; + + delete decJitCache_; + } void TransformDrawEngineDX9::InitDeviceObjects() { @@ -786,7 +792,7 @@ VertexDecoder *TransformDrawEngineDX9::GetVertexDecoder(u32 vtype) { if (iter != decoderMap_.end()) return iter->second; VertexDecoder*dec = new VertexDecoder(); - dec->SetVertexType(vtype, decOptions_); + dec->SetVertexType(vtype, decOptions_, decJitCache_); decoderMap_[vtype] = dec; return dec; } @@ -1293,6 +1299,12 @@ rotateVBO: host->GPUNotifyDraw(); } +void TransformDrawEngineDX9::Resized() { + decJitCache_->Clear(); + + // ... +} + bool TransformDrawEngineDX9::TestBoundingBox(void* control_points, int vertexCount, u32 vertType) { // Simplify away bones and morph before proceeding @@ -1367,6 +1379,10 @@ static Vec3f ScreenToDrawing(const Vec3f& coords) { return ret; } +bool TransformDrawEngineDX9::IsCodePtrVertexDecoder(const u8 *ptr) const { + return decJitCache_->IsInSpace(ptr); +} + // TODO: This probably is not the best interface. bool TransformDrawEngineDX9::GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) { // This is always for the current vertices. diff --git a/GPU/Directx9/TransformPipelineDX9.h b/GPU/Directx9/TransformPipelineDX9.h index 01bf34fbfc..533bcba8bc 100644 --- a/GPU/Directx9/TransformPipelineDX9.h +++ b/GPU/Directx9/TransformPipelineDX9.h @@ -128,11 +128,14 @@ public: void DestroyDeviceObjects(); void GLLost() {}; + void Resized(); // TODO: Call + void DecimateTrackedVertexArrays(); void ClearTrackedVertexArrays(); void SetupVertexDecoder(u32 vertType); + bool IsCodePtrVertexDecoder(const u8 *ptr) const; // This requires a SetupVertexDecoder call first. int EstimatePerVertexCost(); @@ -200,6 +203,8 @@ private: ShaderManagerDX9 *shaderManager_; TextureCacheDX9 *textureCache_; FramebufferManagerDX9 *framebufferManager_; + VertexDecoderJitCache *decJitCache_; + enum { MAX_DEFERRED_DRAW_CALLS = 128 }; DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS];