GLdc/GL/platforms/software.h
GPF f11f7c966a texture: fix Dreamcast hardware texture and scissor regressions
Fix several Dreamcast hardware regressions found while testing real PVR behavior.

- Upload the default white texture through the platform texture loader instead of memcpy directly into PVR texture memory.
- Add GPUTextureLoad so SH4 uses pvr_txr_load while the software backend keeps memcpy behavior.
- Track scissor/userclip application per polygon list and invalidate scissor state at buffer swap.
- Submit queued geometry before USERCLIP/header transitions in the SH4 submit path.
- Remove the stale packed 4bpp source-size double-halving in glTexImage2D.
- Add texture regression coverage for packed 4bpp, unpack row length, compressed palette4 forwarding, and 8bpp-to-4bpp packing.
- Update the scissor sample and add polygon_compare as a small hardware comparison sample.

Verified:
- make -C dcbuild gldc_tests scissor polygon_compare
- scissor sample on Dreamcast hardware
- polygon_compare sample on Dreamcast hardware
- existing strided texture sample on Dreamcast hardware
2026-07-03 09:37:12 -07:00

77 lines
2.1 KiB
C

#pragma once
#include <math.h>
#include <memory.h>
#include "../types.h"
#define __restrict
#define PREFETCH(addr) do {} while(0)
#define MATH_fsrra(x) (1.0f / sqrtf((x)))
#define MATH_Fast_Invert(x) (1.0f / (x))
#define FASTCPY(dst, src, bytes) memcpy(dst, src, bytes)
#define MEMCPY(dst, src, bytes) memcpy(dst, src, bytes)
#define MEMCPY4(dst, src, bytes) memcpy(dst, src, bytes)
#define MEMSET4(dst, v, size) memset((dst), (v), (size))
#define VEC3_NORMALIZE(x, y, z) \
do { \
float l = MATH_fsrra((x) * (x) + (y) * (y) + (z) * (z)); \
x *= l; \
y *= l; \
z *= l; \
} while(0)
#define VEC3_LENGTH(x, y, z, d) \
d = sqrtf((x) * (x) + (y) * (y) + (z) * (z))
#define VEC3_DOT(x1, y1, z1, x2, y2, z2, d) \
d = (x1 * x2) + (y1 * y2) + (z1 * z2)
#ifndef __cplusplus
struct PolyHeader;
struct PolyContext;
#endif
void UploadMatrix4x4(const Matrix4x4* mat);
void MultiplyMatrix4x4(const Matrix4x4* mat);
void DownloadMatrix4x4(Matrix4x4* mat);
/* Transform a 3-element vector in-place using the stored matrix (w == 1) */
void TransformVec3(float* v);
/* Transform a 3-element vector using the stored matrix (w == 1) */
void TransformVec3NoMod(const float* v, float* ret);
/* Transform a 3-element normal using the stored matrix (w == 0)*/
static inline void TransformNormalNoMod(const float* xIn, float* xOut) {
(void) xIn;
(void) xOut;
}
void TransformVertex(float x, float y, float z, float w, float* oxyz, float* ow);
void InitGPU(_Bool autosort, _Bool fsaa);
void ShutdownGPU();
enum GPUPaletteFormat;
size_t GPUMemoryAvailable();
void* GPUMemoryAlloc(size_t size);
void GPUTextureLoad(const void* src, void* dst, size_t size);
void GPUSetPaletteFormat(GPUPaletteFormat format);
void GPUSetPaletteEntry(uint32_t idx, uint32_t value);
void GPUSetBackgroundColour(float r, float g, float b);
void GPUSetAlphaCutOff(uint8_t v);
void GPUSetClearDepth(float v);
void GPUSetFogLinear(float start, float end);
void GPUSetFogExp(float density);
void GPUSetFogExp2(float density);
void GPUSetFogColor(float r, float g, float b, float a);