Add right version of last commit

This commit is contained in:
UnknownShadow200 2024-05-03 23:07:41 +10:00
parent f1fdc2a177
commit 0b8f07f307
5 changed files with 291 additions and 291 deletions

View File

@ -16,16 +16,15 @@
!fv4 = XYZW !fv4 = XYZW
.globl DrawColouredQuads .globl _DrawColouredQuads
.align 4 .align 4
.type DrawColouredQuads,%function .type _DrawColouredQuads,%function
! See https://shared-ptr.com/sh_insns.html ! See https://shared-ptr.com/sh_insns.html
! Although there is fmov.s @Rm+,FRn, there isn't fmov.s FRn,@Rm+ ! Although there is fmov.s @Rm+,FRn, there isn't fmov.s FRn,@Rm+
! So have to use fmov.s FRn,@-Rm instead ! So have to use fmov.s FRn,@-Rm instead
DrawColouredQuads: _DrawColouredQuads:
.fnstart
! Setup ! Setup
mov.l CMD_COL_VERT, r1 ! r1 = GPU VERT command mov.l CMD_COL_VERT, r1 ! r1 = GPU VERT command
mov.l CMD_COL_EOS, r2 ! r2 = GPU EOS command mov.l CMD_COL_EOS, r2 ! r2 = GPU EOS command
@ -121,7 +120,6 @@ DrawColouredQuads:
rts ! return rts ! return
nop nop
.fnend
.align 2 .align 2
CMD_COL_VERT: .long 0xe0000000 CMD_COL_VERT: .long 0xe0000000

View File

@ -16,12 +16,11 @@
!fv4 = XYZW !fv4 = XYZW
.globl DrawTexturedQuads .globl _DrawTexturedQuads
.align 4 .align 4
.type DrawTexturedQuads,%function .type _DrawTexturedQuads,%function
DrawTexturedQuads: _DrawTexturedQuads:
.fnstart
! Setup ! Setup
mov.l CMD_TEX_VERT, r1 ! r1 = GPU VERT command mov.l CMD_TEX_VERT, r1 ! r1 = GPU VERT command
mov.l CMD_TEX_EOS, r2 ! r2 = GPU EOS command mov.l CMD_TEX_EOS, r2 ! r2 = GPU EOS command
@ -123,7 +122,6 @@ DrawTexturedQuads:
rts ! return rts ! return
nop nop
.fnend
.align 2 .align 2
CMD_TEX_VERT: .long 0xe0000000 CMD_TEX_VERT: .long 0xe0000000

View File

@ -1,8 +1,9 @@
BUILD_DIR := build-dc BUILD_DIR := build-dc
SOURCE_DIRS := src third_party/bearssl/src SOURCE_DIRS := src third_party/bearssl/src misc/dreamcast
S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o))) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
CFLAGS :=-g -O1 -pipe -fno-math-errno -Ithird_party/bearssl/inc CFLAGS :=-g -O1 -pipe -fno-math-errno -Ithird_party/bearssl/inc
GLDC_LIB=third_party/gldc/libGLdc.a GLDC_LIB=third_party/gldc/libGLdc.a
@ -31,6 +32,9 @@ $(CC_TEXTURES):
$(BUILD_DIR)/%.o: src/%.c $(BUILD_DIR)/%.o: src/%.c
kos-cc $(CFLAGS) -c $< -o $@ kos-cc $(CFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: misc/dreamcast/%.S
kos-cc -c $< -o $@
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c $(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
kos-cc $(CFLAGS) -c $< -o $@ kos-cc $(CFLAGS) -c $< -o $@

View File

@ -5,6 +5,7 @@
#include "Logger.h" #include "Logger.h"
#include "Window.h" #include "Window.h"
#include "../third_party/gldc/gldc.h" #include "../third_party/gldc/gldc.h"
#include "../third_party/gldc/src/draw.c"
#include <malloc.h> #include <malloc.h>
#include <kos.h> #include <kos.h>
#include <dc/matrix.h> #include <dc/matrix.h>
@ -465,6 +466,22 @@ cc_bool Gfx_WarnIfNecessary(void) {
*----------------------------------------------------------Drawing--------------------------------------------------------* *----------------------------------------------------------Drawing--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
#define VB_PTR gfx_vertices #define VB_PTR gfx_vertices
static const void* VERTEX_PTR;
extern void DrawColouredQuads(const void* src, Vertex* dst, int numQuads);
extern void DrawTexturedQuads(const void* src, Vertex* dst, int numQuads);
void DrawQuads(int count) {
if (!count) return;
Vertex* start = submitVertices(count);
if (TEXTURES_ENABLED) {
DrawTexturedQuads(VERTEX_PTR, start, count >> 2);
} else {
DrawColouredQuads(VERTEX_PTR, start, count >> 2);
}
}
static void SetupVertices(int startVertex) { static void SetupVertices(int startVertex) {
if (gfx_format == VERTEX_FORMAT_TEXTURED) { if (gfx_format == VERTEX_FORMAT_TEXTURED) {
@ -489,29 +506,33 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
} }
void Gfx_DrawVb_Lines(int verticesCount) { void Gfx_DrawVb_Lines(int verticesCount) {
SetupVertices(0); //SetupVertices(0);
//glDrawArrays(GL_LINES, 0, verticesCount); //glDrawArrays(GL_LINES, 0, verticesCount);
} }
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) { void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
SetupVertices(startVertex); if (gfx_format == VERTEX_FORMAT_TEXTURED) {
glDrawArrays(GL_QUADS, 0, verticesCount); VERTEX_PTR = gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED;
} else {
VERTEX_PTR = gfx_vertices + startVertex * SIZEOF_VERTEX_COLOURED;
}
DrawQuads(verticesCount);
} }
void Gfx_DrawVb_IndexedTris(int verticesCount) { void Gfx_DrawVb_IndexedTris(int verticesCount) {
SetupVertices(0); VERTEX_PTR = gfx_vertices;
if (textureOffset) ShiftTextureCoords(verticesCount); if (textureOffset) ShiftTextureCoords(verticesCount);
glDrawArrays(GL_QUADS, 0, verticesCount); DrawQuads(verticesCount);
if (textureOffset) UnshiftTextureCoords(verticesCount); if (textureOffset) UnshiftTextureCoords(verticesCount);
} }
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
if (renderingDisabled) return; if (renderingDisabled) return;
cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; VERTEX_PTR = gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED;
gldcVertexPointer(SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset)); DrawQuads(verticesCount);
glDrawArrays(GL_QUADS, 0, verticesCount);
} }

View File

@ -2,8 +2,6 @@
#include "private.h" #include "private.h"
#include "platform.h" #include "platform.h"
static const GLubyte* VERTEX_PTR;
extern void apply_poly_header(PolyHeader* header, PolyList* activePolyList); extern void apply_poly_header(PolyHeader* header, PolyList* activePolyList);
GL_FORCE_INLINE Vertex* submitVertices(GLuint vertexCount) { GL_FORCE_INLINE Vertex* submitVertices(GLuint vertexCount) {
@ -28,22 +26,3 @@ GL_FORCE_INLINE Vertex* submitVertices(GLuint vertexCount) {
} }
return aligned_vector_at(&output->vector, start_offset); return aligned_vector_at(&output->vector, start_offset);
} }
extern void DrawColouredQuads(Vertex* dst, const GLubyte* src, const GLuint numQuads);
extern void DrawTexturedQuads(Vertex* dst, const GLubyte* src, const GLuint numQuads);
void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) {
TRACE();
if (!count) return;
Vertex* start = submitVertices(count);
if (TEXTURES_ENABLED) {
DrawTexturedQuads(start, VERTEX_PTR + (first * 24), count >> 2);
} else {
DrawColouredQuads(start, VERTEX_PTR + (first * 16), count >> 2);
}
}
void APIENTRY gldcVertexPointer(GLsizei stride, const GLvoid * pointer) {
VERTEX_PTR = pointer;
}