Minor code cleanups

This commit is contained in:
Henrik Rydgård 2024-10-28 17:39:49 +01:00
parent ffb3e61ca6
commit 1221a6e928
11 changed files with 13 additions and 27 deletions

View File

@ -363,7 +363,7 @@ void RingbufferLogListener::Log(const LogMessage &message) {
#ifdef _WIN32
void OutputDebugStringUTF8(const char *p) {
wchar_t temp[16384*4];
wchar_t *temp = new wchar_t[65536];
int len = std::min(16383*4, (int)strlen(p));
int size = (int)MultiByteToWideChar(CP_UTF8, 0, p, len, NULL, 0);
@ -371,6 +371,7 @@ void OutputDebugStringUTF8(const char *p) {
temp[size] = 0;
OutputDebugString(temp);
delete[] temp;
}
#else

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <algorithm>
#include <cstdint>
@ -65,7 +65,7 @@ template <typename Value>
class TweenBase: public Tween {
public:
TweenBase(float duration, float (*curve)(float) = [](float f) { return f; })
: Tween(duration, curve) {
: Tween(duration, curve), from{}, to_{} {
}
TweenBase(Value from, Value to, float duration, float (*curve)(float) = [](float f) { return f; })
: Tween(duration, curve), from_(from), to_(to) {

View File

@ -44,6 +44,7 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(16) {
transformedExpanded_ = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decoded_ = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
decIndex_ = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE);
indexGen.Setup(decIndex_);
}
DrawEngineCommon::~DrawEngineCommon() {

View File

@ -1911,8 +1911,8 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w,
struct CopyCandidate {
VirtualFramebuffer *vfb = nullptr;
int y;
int h;
int y = 0;
int h = 0;
std::string ToString(RasterChannel channel) const {
return StringFromFormat("%08x %s %dx%d y=%d h=%d", vfb->Address(channel), GeBufferFormatToString(vfb->Format(channel)), vfb->width, vfb->height, y, h);

View File

@ -91,7 +91,7 @@ bool IsAlphaTestTriviallyTrue() {
return false;
}
// Fallthrough on purpose
[[fallthrough]];
case GE_COMP_GREATER:
{
// If the texture and vertex only use 1.0 alpha, then the ref value doesn't matter.

View File

@ -48,11 +48,6 @@ const u8 IndexGenerator::indexedPrimitiveType[7] = {
GE_PRIM_RECTANGLES,
};
void IndexGenerator::Setup(u16 *inds) {
this->indsBase_ = inds;
Reset();
}
void IndexGenerator::AddPrim(int prim, int vertexCount, int indexOffset, bool clockwise) {
switch (prim) {
case GE_PRIM_POINTS: AddPoints(vertexCount, indexOffset); break;

View File

@ -24,9 +24,12 @@
class IndexGenerator {
public:
void Setup(u16 *indexptr);
void Setup(u16 *indexptr) {
indsBase_ = indexptr;
inds_ = indexptr;
}
void Reset() {
this->inds_ = indsBase_;
inds_ = indsBase_;
}
static bool PrimCompatible(int prim1, int prim2) {

View File

@ -80,16 +80,7 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device,
decOptions_.expandAllWeightsToFloat = true;
decOptions_.expand8BitNormalsToFloat = true;
// Allocate nicely aligned memory. Maybe graphics drivers will
// appreciate it.
// All this is a LOT of memory, need to see if we can cut down somehow.
indexGen.Setup(decIndex_);
InitDeviceObjects();
// Vertex pushing buffers. For uniforms we use short DISCARD buffers, but we could use
// this kind of buffer there as well with D3D11.1. We might be able to use the same buffer
// for both vertices and indices, and possibly all three data types.
}
DrawEngineD3D11::~DrawEngineD3D11() {

View File

@ -89,8 +89,6 @@ DrawEngineDX9::DrawEngineDX9(Draw::DrawContext *draw) : draw_(draw), vertexDeclM
decOptions_.expandAllWeightsToFloat = true;
decOptions_.expand8BitNormalsToFloat = true;
indexGen.Setup(decIndex_);
InitDeviceObjects();
tessDataTransferDX9 = new TessellationDataTransferDX9();

View File

@ -67,8 +67,6 @@ DrawEngineGLES::DrawEngineGLES(Draw::DrawContext *draw) : inputLayoutMap_(16), d
decOptions_.expandAllWeightsToFloat = false;
decOptions_.expand8BitNormalsToFloat = false;
indexGen.Setup(decIndex_);
InitDeviceObjects();
tessDataTransferGLES = new TessellationDataTransferGLES(render_);

View File

@ -62,7 +62,6 @@ DrawEngineVulkan::DrawEngineVulkan(Draw::DrawContext *draw)
: draw_(draw) {
decOptions_.expandAllWeightsToFloat = false;
decOptions_.expand8BitNormalsToFloat = false;
indexGen.Setup(decIndex_);
}
void DrawEngineVulkan::InitDeviceObjects() {