mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Revert: Sprite sorting optimisation sorted incorrectly.
This reverts commit 25ab9c1997
.
This commit is contained in:
parent
68e6b5531a
commit
1a1204472e
@ -88,7 +88,6 @@
|
|||||||
#include "command_func.h"
|
#include "command_func.h"
|
||||||
#include "network/network_func.h"
|
#include "network/network_func.h"
|
||||||
#include "framerate_type.h"
|
#include "framerate_type.h"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@ -1380,22 +1379,11 @@ static bool ViewportSortParentSpritesChecker()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CDECL CompareParentSprites(ParentSpriteToDraw * const *psd, ParentSpriteToDraw * const *psd2)
|
|
||||||
{
|
|
||||||
const ParentSpriteToDraw *ps = *psd;
|
|
||||||
const ParentSpriteToDraw *ps2 = *psd2;
|
|
||||||
return ps->xmin - ps2->xmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sort parent sprites pointer array */
|
/** Sort parent sprites pointer array */
|
||||||
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
|
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
|
||||||
{
|
{
|
||||||
ParentSpriteToDraw **psdvend = psdv->End();
|
ParentSpriteToDraw **psdvend = psdv->End();
|
||||||
ParentSpriteToDraw **psd = psdv->Begin();
|
ParentSpriteToDraw **psd = psdv->Begin();
|
||||||
|
|
||||||
/* pre-sort by xmin in ascending order */
|
|
||||||
QSortT(psd, psdvend - psd, CompareParentSprites);
|
|
||||||
|
|
||||||
while (psd != psdvend) {
|
while (psd != psdvend) {
|
||||||
ParentSpriteToDraw *ps = *psd;
|
ParentSpriteToDraw *ps = *psd;
|
||||||
|
|
||||||
@ -1432,11 +1420,9 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
|
|||||||
* I.e. every single order of X, Y, Z says ps2 is behind ps or they overlap.
|
* I.e. every single order of X, Y, Z says ps2 is behind ps or they overlap.
|
||||||
* That is: If one partial order says ps behind ps2, do not change the order.
|
* That is: If one partial order says ps behind ps2, do not change the order.
|
||||||
*/
|
*/
|
||||||
if (ps->xmax < ps2->xmin) {
|
if (ps->xmax < ps2->xmin ||
|
||||||
/* all following sprites have xmin >= ps2->xmin */
|
ps->ymax < ps2->ymin ||
|
||||||
break;
|
ps->zmax < ps2->zmin) {
|
||||||
}
|
|
||||||
if (ps->ymax < ps2->ymin || ps->zmax < ps2->zmin) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "smmintrin.h"
|
#include "smmintrin.h"
|
||||||
#include "viewport_sprite_sorter.h"
|
#include "viewport_sprite_sorter.h"
|
||||||
#include "core/sort_func.hpp"
|
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
@ -26,24 +25,12 @@
|
|||||||
#define LOAD_128 _mm_loadu_si128
|
#define LOAD_128 _mm_loadu_si128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int CDECL CompareParentSprites(ParentSpriteToDraw * const *psd, ParentSpriteToDraw * const *psd2)
|
|
||||||
{
|
|
||||||
const ParentSpriteToDraw *ps = *psd;
|
|
||||||
const ParentSpriteToDraw *ps2 = *psd2;
|
|
||||||
return ps->xmin - ps2->xmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sort parent sprites pointer array using SSE4.1 optimizations. */
|
/** Sort parent sprites pointer array using SSE4.1 optimizations. */
|
||||||
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
||||||
{
|
{
|
||||||
const __m128i mask_ptest = _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0);
|
const __m128i mask_ptest = _mm_setr_epi8(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0);
|
||||||
const __m128i mask_ptest2 = _mm_setr_epi8(-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
||||||
ParentSpriteToDraw ** const psdvend = psdv->End();
|
ParentSpriteToDraw ** const psdvend = psdv->End();
|
||||||
ParentSpriteToDraw **psd = psdv->Begin();
|
ParentSpriteToDraw **psd = psdv->Begin();
|
||||||
|
|
||||||
/* pre-sort by xmin in ascending order */
|
|
||||||
QSortT(psd, psdvend - psd, CompareParentSprites);
|
|
||||||
|
|
||||||
while (psd != psdvend) {
|
while (psd != psdvend) {
|
||||||
ParentSpriteToDraw * const ps = *psd;
|
ParentSpriteToDraw * const ps = *psd;
|
||||||
|
|
||||||
@ -77,14 +64,8 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv)
|
|||||||
__m128i ps1_max = LOAD_128((__m128i*) &ps->xmax);
|
__m128i ps1_max = LOAD_128((__m128i*) &ps->xmax);
|
||||||
__m128i ps2_min = LOAD_128((__m128i*) &ps2->xmin);
|
__m128i ps2_min = LOAD_128((__m128i*) &ps2->xmin);
|
||||||
__m128i rslt1 = _mm_cmplt_epi32(ps1_max, ps2_min);
|
__m128i rslt1 = _mm_cmplt_epi32(ps1_max, ps2_min);
|
||||||
if (!_mm_testz_si128(mask_ptest, rslt1)) {
|
if (!_mm_testz_si128(mask_ptest, rslt1))
|
||||||
if (!_mm_testz_si128(mask_ptest2, rslt1) /* ps->xmax < ps2->xmin */) {
|
continue;
|
||||||
/* all following sprites have xmin >= ps2->xmin */
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__m128i ps1_min = LOAD_128((__m128i*) &ps->xmin);
|
__m128i ps1_min = LOAD_128((__m128i*) &ps->xmin);
|
||||||
__m128i ps2_max = LOAD_128((__m128i*) &ps2->xmax);
|
__m128i ps2_max = LOAD_128((__m128i*) &ps2->xmax);
|
||||||
|
Loading…
Reference in New Issue
Block a user