mirror of https://github.com/bsnes-emu/bsnes.git
Fix #172. Allow unroll optimizations when compiling with GCC.
This commit is contained in:
parent
1433c59778
commit
06670fc970
12
Core/apu.c
12
Core/apu.c
|
@ -69,9 +69,7 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsign
|
|||
static void render(GB_gameboy_t *gb, bool no_downsampling, GB_sample_t *dest)
|
||||
{
|
||||
GB_sample_t output = {0,0};
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
|
||||
for (unsigned i = GB_N_CHANNELS; i--;) {
|
||||
double multiplier = CH_STEP;
|
||||
if (!is_DAC_enabled(gb, i)) {
|
||||
|
@ -128,9 +126,7 @@ static void render(GB_gameboy_t *gb, bool no_downsampling, GB_sample_t *dest)
|
|||
unsigned mask = gb->io_registers[GB_IO_NR51];
|
||||
unsigned left_volume = 0;
|
||||
unsigned right_volume = 0;
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned i = GB_N_CHANNELS; i--;) {
|
||||
if (gb->apu.is_active[i]) {
|
||||
if (mask & 1) {
|
||||
|
@ -378,9 +374,7 @@ void GB_apu_run(GB_gameboy_t *gb)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned i = GB_SQUARE_2 + 1; i--;) {
|
||||
if (gb->apu.is_active[i]) {
|
||||
uint8_t cycles_left = cycles;
|
||||
|
|
|
@ -27,9 +27,7 @@ static GB_fifo_item_t *fifo_pop(GB_fifo_t *fifo)
|
|||
static void fifo_push_bg_row(GB_fifo_t *fifo, uint8_t lower, uint8_t upper, uint8_t palette, bool bg_priority, bool flip_x)
|
||||
{
|
||||
if (!flip_x) {
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned i = 8; i--;) {
|
||||
fifo->fifo[fifo->write_end] = (GB_fifo_item_t) {
|
||||
(lower >> 7) | ((upper >> 7) << 1),
|
||||
|
@ -45,9 +43,7 @@ static void fifo_push_bg_row(GB_fifo_t *fifo, uint8_t lower, uint8_t upper, uint
|
|||
}
|
||||
}
|
||||
else {
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned i = 8; i--;) {
|
||||
fifo->fifo[fifo->write_end] = (GB_fifo_item_t) {
|
||||
(lower & 1) | ((upper & 1) << 1),
|
||||
|
@ -74,9 +70,7 @@ static void fifo_overlay_object_row(GB_fifo_t *fifo, uint8_t lower, uint8_t uppe
|
|||
|
||||
uint8_t flip_xor = flip_x? 0: 0x7;
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned i = 8; i--;) {
|
||||
uint8_t pixel = (lower >> 7) | ((upper >> 7) << 1);
|
||||
GB_fifo_item_t *target = &fifo->fifo[(fifo->read_end + (i ^ flip_xor)) & (GB_FIFO_LENGTH - 1)];
|
||||
|
@ -1123,9 +1117,7 @@ uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_h
|
|||
}
|
||||
|
||||
for (unsigned y = 0; y < *sprite_height; y++) {
|
||||
#ifdef __clang__
|
||||
#pragma unroll
|
||||
#endif
|
||||
UNROLL
|
||||
for (unsigned x = 0; x < 8; x++) {
|
||||
uint8_t color = (((gb->vram[vram_address ] >> ((~x)&7)) & 1 ) |
|
||||
((gb->vram[vram_address + 1] >> ((~x)&7)) & 1) << 1 );
|
||||
|
|
|
@ -29,6 +29,15 @@
|
|||
#define GB_MODEL_MGB_FAMILY 0x100
|
||||
#define GB_MODEL_CGB_FAMILY 0x200
|
||||
#define GB_MODEL_PAL_BIT 0x1000
|
||||
|
||||
#if __clang__
|
||||
#define UNROLL _Pragma("unroll")
|
||||
#elif __GNUC__
|
||||
#define UNROLL _Pragma("GCC unroll 8")
|
||||
#else
|
||||
#define UNROLL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
|
2
Makefile
2
Makefile
|
@ -204,7 +204,7 @@ $(BIN)/SameBoy.app/Contents/MacOS/SameBoy: $(CORE_OBJECTS) $(COCOA_OBJECTS)
|
|||
-@$(MKDIR) -p $(dir $@)
|
||||
$(CC) $^ -o $@ $(LDFLAGS) -framework OpenGL -framework AudioUnit -framework AVFoundation -framework CoreVideo -framework CoreMedia -framework IOKit
|
||||
ifeq ($(CONF), release)
|
||||
strip $@
|
||||
#strip $@
|
||||
endif
|
||||
|
||||
$(BIN)/SameBoy.app/Contents/Resources/Base.lproj/%.nib: Cocoa/%.xib
|
||||
|
|
Loading…
Reference in New Issue