diff --git a/CMakeLists.txt b/CMakeLists.txt index 68813657e2..63ee23dbde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1005,6 +1005,7 @@ add_library(GPU OBJECT GPU/Common/IndexGenerator.h GPU/Common/TextureDecoder.cpp GPU/Common/TextureDecoder.h + GPU/Common/SplineCommon.h GPU/GLES/GLES_GPU.cpp GPU/GLES/GLES_GPU.h GPU/GLES/FragmentShaderGenerator.cpp diff --git a/GPU/Common/SplineCommon.h b/GPU/Common/SplineCommon.h new file mode 100644 index 0000000000..2b75cd9c8d --- /dev/null +++ b/GPU/Common/SplineCommon.h @@ -0,0 +1,29 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#pragma once + +#include "Common/CommonTypes.h" +#include "GPU/Math3D.h" + +// PSP compatible format so we can use the end of the pipeline in beziers etc +struct SimpleVertex { + float uv[2]; + u8 color[4]; + Vec3f nrm; + Vec3f pos; +}; diff --git a/GPU/GLES/Spline.cpp b/GPU/GLES/Spline.cpp index 0f1e8a7375..747f19815d 100644 --- a/GPU/GLES/Spline.cpp +++ b/GPU/GLES/Spline.cpp @@ -19,6 +19,7 @@ #include "Core/Config.h" #include "Core/MemMap.h" #include "GPU/Math3D.h" +#include "GPU/Common/SplineCommon.h" // Here's how to evaluate them fast: // http://and-what-happened.blogspot.se/2012/07/evaluating-b-splines-aka-basis-splines.html @@ -418,6 +419,9 @@ void TesselateSplinePatch(u8 *&dest, int &count, const SplinePatch &spatch, u32 // First compute all the vertices and put them in an array SimpleVertex *vertices = new SimpleVertex[(patch_div_s + 1) * (patch_div_t + 1)]; + float tu_width = 1.0f + (spatch.count_u - 4) * 1.0f/3.0f; + float tv_height = 1.0f + (spatch.count_v - 4) * 1.0f/3.0f; + bool computeNormals = gstate.isLightingEnabled(); for (int tile_v = 0; tile_v < patch_div_t + 1; tile_v++) { float v = ((float)tile_v * (float)(m - 2) / (float)(patch_div_t + 0.00001f)); // epsilon to prevent division by 0 in spline_s @@ -441,8 +445,8 @@ void TesselateSplinePatch(u8 *&dest, int &count, const SplinePatch &spatch, u32 vert->uv[0] = 0.0f; vert->uv[1] = 0.0f; } else { - vert->uv[0] = ((float)tile_u / (float)patch_div_s); - vert->uv[1] = ((float)tile_v / (float)patch_div_t); + vert->uv[0] = tu_width * ((float)tile_u / (float)patch_div_s); + vert->uv[1] = tv_height * ((float)tile_v / (float)patch_div_t); } // Collect influences from surrounding control points. diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index b395c1177e..aec38005af 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -90,14 +90,6 @@ public: u16 drawsUntilNextFullHash; }; -// PSP compatible format so we can use the end of the pipeline in beziers etc -struct SimpleVertex { - float uv[2]; - u8 color[4]; - Vec3f nrm; - Vec3f pos; -}; - // Handles transform, lighting and drawing. class TransformDrawEngine : public GfxResourceHolder { public: diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index b1d996299b..3cc20ae963 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -157,6 +157,7 @@ + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index 08238970d6..56d1d341e9 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -144,6 +144,9 @@ Common + + Common +