Fix build issues

This commit is contained in:
Isaac Aronson
2023-09-12 19:18:26 -05:00
committed by Sam Lantinga
parent 594ca1a897
commit f0238ef615
2 changed files with 24 additions and 17 deletions
@@ -194,6 +194,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\Test\testautomation.c" /> <ClCompile Include="..\..\..\Test\testautomation.c" />
<ClCompile Include="..\..\..\test\testautomation_audio.c" /> <ClCompile Include="..\..\..\test\testautomation_audio.c" />
<ClCompile Include="..\..\..\test\testautomation_blit.c" />
<ClCompile Include="..\..\..\test\testautomation_clipboard.c" /> <ClCompile Include="..\..\..\test\testautomation_clipboard.c" />
<ClCompile Include="..\..\..\test\testautomation_events.c" /> <ClCompile Include="..\..\..\test\testautomation_events.c" />
<ClCompile Include="..\..\..\test\testautomation_guid.c" /> <ClCompile Include="..\..\..\test\testautomation_guid.c" />
@@ -232,4 +233,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
+22 -16
View File
@@ -13,6 +13,9 @@
#include <stdio.h> #include <stdio.h>
#ifndef _MSC_VER #ifndef _MSC_VER
#include <unistd.h> #include <unistd.h>
#else
/* Suppress uint64 to uint32 conversion warning within the PRNG engine */
#pragma warning( disable : 4244 )
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@@ -46,7 +49,8 @@ void blitSetUp(void *arg) {
*/ */
Uint32 *getNextRandomBuffer(const int width, const int height) { Uint32 *getNextRandomBuffer(const int width, const int height) {
Uint32* buf = SDL_malloc(sizeof(Uint32) * width * height); Uint32* buf = SDL_malloc(sizeof(Uint32) * width * height);
for (int i = 0; i < width * height; i++) { int i;
for (i = 0; i < width * height; i++) {
buf[i] = getRandomUint32(); buf[i] = getRandomUint32();
} }
return buf; return buf;
@@ -66,11 +70,12 @@ SDL_Surface* getRandomSVGASurface(Uint32 *pixels, SDL_PixelFormatEnum format) {
/* /*
* Calculates the FNV-1a hash of input pixel data * Calculates the FNV-1a hash of input pixel data
*/ */
Uint32 FNVHash(Uint32* buf, unsigned int length) { Uint32 FNVHash(Uint32* buf, int length) {
const Uint32 fnv_prime = 0x811C9DC5; const Uint32 fnv_prime = 0x811C9DC5;
Uint32 hash = 0; Uint32 hash = 0;
int i;
for (int i = 0; i < length; buf++, i++) for (i = 0; i < length; buf++, i++)
{ {
hash *= fnv_prime; hash *= fnv_prime;
hash ^= (*buf); hash ^= (*buf);
@@ -93,8 +98,8 @@ Uint32 hashSurfacePixels(SDL_Surface * surface) {
int blit_testExampleApplicationRender(void *arg) { int blit_testExampleApplicationRender(void *arg) {
const int width = 32; const int width = 32;
const int height = 32; const int height = 32;
const Uint32 scalar_hash = 0xf47a3f55; const unsigned long scalar_hash = 0xf47a3f55;
const Uint32 x86_simd_hash = 0xe345d7a7; const unsigned long x86_simd_hash = 0xe345d7a7;
SDL_Surface* dest_surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_ARGB8888); SDL_Surface* dest_surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface* rainbow_background = SDLTest_ImageBlendingBackground(); SDL_Surface* rainbow_background = SDLTest_ImageBlendingBackground();
SDL_Surface* gearbrain_sprite = SDLTest_ImageBlendingSprite(); SDL_Surface* gearbrain_sprite = SDLTest_ImageBlendingSprite();
@@ -103,9 +108,9 @@ int blit_testExampleApplicationRender(void *arg) {
// Blit example game sprite onto "screen" // Blit example game sprite onto "screen"
SDL_BlitSurface(gearbrain_sprite, NULL, dest_surface, NULL); SDL_BlitSurface(gearbrain_sprite, NULL, dest_surface, NULL);
// Check result // Check result
Uint32 hash = hashSurfacePixels(dest_surface); const unsigned long hash = hashSurfacePixels(dest_surface);
SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash, SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash,
"Should render identically, expected 0x%x (scalar) or 0x%x (x86_simd), got 0x%x", "Should render identically, expected 0x%lx (scalar) or 0x%lx (x86_simd), got 0x%lx",
scalar_hash, x86_simd_hash, hash); scalar_hash, x86_simd_hash, hash);
// Clean up // Clean up
SDL_DestroySurface(rainbow_background); SDL_DestroySurface(rainbow_background);
@@ -121,8 +126,8 @@ int blit_testExampleApplicationRender(void *arg) {
int blit_testRandomToRandomSVGA(void *arg) { int blit_testRandomToRandomSVGA(void *arg) {
const int width = 800; const int width = 800;
const int height = 600; const int height = 600;
const Uint32 scalar_hash = 0x1f56efad; const unsigned long scalar_hash = 0x1f56efad;
const Uint32 x86_simd_hash = 0x42140c5f; const unsigned long x86_simd_hash = 0x42140c5f;
// Allocate random buffers // Allocate random buffers
Uint32 *dest_pixels = getNextRandomBuffer(width, height); Uint32 *dest_pixels = getNextRandomBuffer(width, height);
Uint32 *src_pixels = getNextRandomBuffer(width, height); Uint32 *src_pixels = getNextRandomBuffer(width, height);
@@ -132,9 +137,9 @@ int blit_testRandomToRandomSVGA(void *arg) {
// Blit surfaces // Blit surfaces
SDL_BlitSurface(src_surface, NULL, dest_surface, NULL); SDL_BlitSurface(src_surface, NULL, dest_surface, NULL);
// Check result // Check result
Uint32 hash = hashSurfacePixels(dest_surface); const unsigned long hash = hashSurfacePixels(dest_surface);
SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash, SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash,
"Should render identically, expected 0x%x (scalar) or 0x%x (x86_simd), got 0x%x", "Should render identically, expected 0x%lx (scalar) or 0x%lx (x86_simd), got 0x%lx",
scalar_hash, x86_simd_hash, hash); scalar_hash, x86_simd_hash, hash);
// Clean up // Clean up
SDL_DestroySurface(dest_surface); SDL_DestroySurface(dest_surface);
@@ -151,13 +156,14 @@ int blit_testRandomToRandomSVGA(void *arg) {
int blit_testRandomToRandomSVGAMultipleIterations(void *arg) { int blit_testRandomToRandomSVGAMultipleIterations(void *arg) {
const int width = 800; const int width = 800;
const int height = 600; const int height = 600;
const Uint32 x86_simd_hash = 0x2626be78; int i;
const Uint32 scalar_hash = 0xfb2a8ee8; const unsigned long x86_simd_hash = 0x2626be78;
const unsigned long scalar_hash = 0xfb2a8ee8;
// Create blank source surface // Create blank source surface
SDL_Surface* dest_surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_ABGR8888); SDL_Surface* dest_surface = SDL_CreateSurface(width, height, SDL_PIXELFORMAT_ABGR8888);
// Perform 250k random blits into random areas of the blank surface // Perform 250k random blits into random areas of the blank surface
for (int i = 0; i < 250000; i++) { for (i = 0; i < 250000; i++) {
Uint32 *buf = getNextRandomBuffer(15, 15); Uint32 *buf = getNextRandomBuffer(15, 15);
SDL_Surface *sourceSurface = getRandomBlitChunk(buf, SDL_PIXELFORMAT_RGBA8888); SDL_Surface *sourceSurface = getRandomBlitChunk(buf, SDL_PIXELFORMAT_RGBA8888);
@@ -172,12 +178,12 @@ int blit_testRandomToRandomSVGAMultipleIterations(void *arg) {
SDL_free(buf); SDL_free(buf);
} }
// Check result // Check result
Uint32 hash = hashSurfacePixels(dest_surface); const unsigned long hash = hashSurfacePixels(dest_surface);
// Clean up // Clean up
SDL_SaveBMP(dest_surface, "250k_scalar.bmp"); SDL_SaveBMP(dest_surface, "250k_scalar.bmp");
SDL_DestroySurface(dest_surface); SDL_DestroySurface(dest_surface);
SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash, SDLTest_AssertCheck(hash == scalar_hash || hash == x86_simd_hash,
"Should render identically, expected 0x%x (scalar) or 0x%x (x86_simd), got 0x%x", "Should render identically, expected 0x%lx (scalar) or 0x%lx (x86_simd), got 0x%lx",
scalar_hash, x86_simd_hash, hash); scalar_hash, x86_simd_hash, hash);
return TEST_COMPLETED; return TEST_COMPLETED;
} }