mirror of
https://github.com/sarah-walker-pcem/pcem.git
synced 2025-07-23 03:33:02 +02:00
viewers: Add 3DFX viewer
Add a viewer for 3DFX state. This shows all triangles and textures involved in the most recent frame, and allows showing of framebuffer, depth buffer, and wireframes. It currently does not work properly in SLI configurations (only the first card will be viewed) and trilinear textures will not display correctly.
This commit is contained in:
@@ -134,7 +134,7 @@ find_package(OpenAL REQUIRED)
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
|
||||
if(${PCEM_DISPLAY_ENGINE} STREQUAL "wxWidgets")
|
||||
find_package(wxWidgets REQUIRED COMPONENTS core base xrc)
|
||||
find_package(wxWidgets REQUIRED COMPONENTS core base xrc adv)
|
||||
include(${wxWidgets_USE_FILE})
|
||||
set(DISPLAY_ENGINE_LIBRARIES ${wxWidgets_LIBRARIES})
|
||||
endif()
|
||||
|
@@ -294,6 +294,7 @@ typedef struct voodoo_t {
|
||||
unsigned int vertex_next_age;
|
||||
int num_verticies;
|
||||
int cull_pingpong;
|
||||
int in_strip;
|
||||
|
||||
int flush;
|
||||
|
||||
@@ -463,6 +464,8 @@ typedef struct voodoo_t {
|
||||
uint8_t *vram, *changedvram;
|
||||
|
||||
void *p;
|
||||
|
||||
int viewer_active;
|
||||
} voodoo_t;
|
||||
|
||||
typedef struct voodoo_set_t {
|
||||
|
@@ -15,12 +15,16 @@ void viewer_add(char *title, viewer_t *viewer, void *p);
|
||||
void viewer_open(void *hwnd, int id);
|
||||
void viewer_remove(void *viewer);
|
||||
void viewer_update(viewer_t *viewer, void *p);
|
||||
void viewer_call(viewer_t *viewer, void *p, void (*func)(void *v, void *param), void *param);
|
||||
void viewer_close_all();
|
||||
void viewer_notify_pause();
|
||||
void viewer_notify_resume();
|
||||
void update_viewers_menu(void *menu);
|
||||
|
||||
extern viewer_t viewer_font;
|
||||
extern viewer_t viewer_palette;
|
||||
extern viewer_t viewer_palette_16;
|
||||
extern viewer_t viewer_voodoo;
|
||||
extern viewer_t viewer_vram;
|
||||
|
||||
#define IDM_VIEWER 1600
|
||||
@@ -45,6 +49,14 @@ public:
|
||||
virtual ~Viewer()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void NotifyPause()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void NotifyResume()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
18
includes/private/wx-ui/viewer_voodoo.h
Normal file
18
includes/private/wx-ui/viewer_voodoo.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _VIEWER_VOODOO_H_
|
||||
#define _VIEWER_VOODOO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void voodoo_viewer_swap_buffer(void *v, void *param);
|
||||
void voodoo_viewer_queue_triangle(void *v, void *param);
|
||||
void voodoo_viewer_begin_strip(void *v, void *param);
|
||||
void voodoo_viewer_end_strip(void *v, void *param);
|
||||
void voodoo_viewer_use_texture(void *v, void *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -20,6 +20,7 @@
|
||||
#include "vid_voodoo_regs.h"
|
||||
#include "vid_voodoo_render.h"
|
||||
#include "vid_voodoo_texture.h"
|
||||
#include "viewer.h"
|
||||
|
||||
rgba8_t rgb332[0x100], ai44[0x100], rgb565[0x10000], argb1555[0x10000], argb4444[0x10000], ai88[0x10000];
|
||||
|
||||
@@ -1156,6 +1157,8 @@ void *voodoo_2d3d_card_init(int type) {
|
||||
voodoo->disp_buffer = 0;
|
||||
voodoo->draw_buffer = 1;
|
||||
|
||||
viewer_add("3DFX Voodoo render", &viewer_voodoo, voodoo);
|
||||
|
||||
return voodoo;
|
||||
}
|
||||
|
||||
@@ -1209,6 +1212,8 @@ void *voodoo_init() {
|
||||
mem_mapping_add(&voodoo_set->snoop_mapping, 0, 0, NULL, voodoo_snoop_readw, voodoo_snoop_readl, NULL, voodoo_snoop_writew,
|
||||
voodoo_snoop_writel, NULL, MEM_MAPPING_EXTERNAL, voodoo_set);
|
||||
|
||||
viewer_add("3DFX Voodoo render", &viewer_voodoo, voodoo_set->voodoos[0]);
|
||||
|
||||
return voodoo_set;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include "vid_voodoo_render.h"
|
||||
#include "vid_voodoo_setup.h"
|
||||
#include "vid_voodoo_texture.h"
|
||||
#include "viewer.h"
|
||||
#include "viewer_voodoo.h"
|
||||
|
||||
enum { CHIP_FBI = 0x1, CHIP_TREX0 = 0x2, CHIP_TREX1 = 0x4, CHIP_TREX2 = 0x8 };
|
||||
|
||||
@@ -43,6 +45,8 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) {
|
||||
// pclog("swapbufferCMD %08x %08x\n", val, voodoo->leftOverlayBuf);
|
||||
|
||||
voodoo_wait_for_render_thread_idle(voodoo);
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_swap_buffer, NULL);
|
||||
if (!(val & 1)) {
|
||||
banshee_set_overlay_addr(voodoo->p, voodoo->leftOverlayBuf);
|
||||
thread_lock_mutex(voodoo->swap_mutex);
|
||||
@@ -82,6 +86,8 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) {
|
||||
// pclog("Swap buffer %08x %d %p %i\n", val, voodoo->swap_count, &voodoo->swap_count, (voodoo ==
|
||||
// voodoo->set->voodoos[1]) ? 1 : 0); voodoo->front_offset = params->front_offset;
|
||||
voodoo_wait_for_render_thread_idle(voodoo);
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_swap_buffer, NULL);
|
||||
if (!(val & 1)) {
|
||||
memset(voodoo->dirty_line, 1, sizeof(voodoo->dirty_line));
|
||||
voodoo->front_offset = voodoo->params.front_offset;
|
||||
@@ -265,6 +271,11 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) {
|
||||
|
||||
case SST_triangleCMD:
|
||||
case SST_remap_triangleCMD:
|
||||
if (voodoo->in_strip) {
|
||||
voodoo->in_strip = 0;
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_end_strip, NULL);
|
||||
}
|
||||
voodoo->params.sign = val & (1 << 31);
|
||||
|
||||
if (voodoo->ncc_dirty[0])
|
||||
@@ -466,6 +477,11 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) {
|
||||
break;
|
||||
|
||||
case SST_ftriangleCMD:
|
||||
if (voodoo->in_strip) {
|
||||
voodoo->in_strip = 0;
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_end_strip, NULL);
|
||||
}
|
||||
voodoo->params.sign = val & (1 << 31);
|
||||
|
||||
if (voodoo->ncc_dirty[0])
|
||||
@@ -745,6 +761,9 @@ void voodoo_reg_writel(uint32_t addr, uint32_t val, void *p) {
|
||||
|
||||
voodoo->num_verticies = 1;
|
||||
voodoo->cull_pingpong = 0;
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_begin_strip, NULL);
|
||||
voodoo->in_strip = 1;
|
||||
break;
|
||||
case SST_sDrawTriCMD:
|
||||
// pclog("sDrawTriCMD %i %i\n", voodoo->num_verticies, voodoo->sSetupMode & SETUPMODE_STRIP_MODE);
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "vid_voodoo_regs.h"
|
||||
#include "vid_voodoo_render.h"
|
||||
#include "vid_voodoo_texture.h"
|
||||
#include "viewer.h"
|
||||
#include "viewer_voodoo.h"
|
||||
|
||||
typedef struct voodoo_state_t {
|
||||
int xstart, xend, xdir;
|
||||
@@ -1504,6 +1506,9 @@ void voodoo_queue_triangle(voodoo_t *voodoo, voodoo_params_t *params) {
|
||||
if (voodoo->dual_tmus)
|
||||
voodoo_use_texture(voodoo, params, 1);
|
||||
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_queue_triangle, NULL);
|
||||
|
||||
memcpy(params_new, params, sizeof(voodoo_params_t));
|
||||
|
||||
voodoo->params_write_idx++;
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#include "vid_voodoo_regs.h"
|
||||
#include "vid_voodoo_render.h"
|
||||
#include "vid_voodoo_texture.h"
|
||||
#include "viewer.h"
|
||||
#include "viewer_voodoo.h"
|
||||
|
||||
void voodoo_recalc_tex(voodoo_t *voodoo, int tmu) {
|
||||
int aspect = (voodoo->params.tLOD[tmu] >> 21) & 3;
|
||||
@@ -133,6 +135,7 @@ void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) {
|
||||
else
|
||||
addr = params->texBaseAddr[tmu];
|
||||
|
||||
|
||||
/*Try to find texture in cache*/
|
||||
for (c = 0; c < TEX_CACHE_MAX; c++) {
|
||||
if (voodoo->texture_cache[tmu][c].base == addr &&
|
||||
@@ -140,6 +143,8 @@ void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) {
|
||||
voodoo->texture_cache[tmu][c].palette_checksum == palette_checksum) {
|
||||
params->tex_entry[tmu] = c;
|
||||
voodoo->texture_cache[tmu][c].refcount++;
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_use_texture, (void *)(uintptr_t)tmu);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -428,6 +433,9 @@ void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu) {
|
||||
|
||||
params->tex_entry[tmu] = c;
|
||||
voodoo->texture_cache[tmu][c].refcount++;
|
||||
|
||||
if (voodoo->viewer_active)
|
||||
viewer_call(&viewer_voodoo, voodoo, voodoo_viewer_use_texture, (void *)(uintptr_t)tmu);
|
||||
}
|
||||
|
||||
void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu) {
|
||||
|
@@ -50,7 +50,7 @@ void viewer_add(char *title, viewer_t *viewer, void *p)
|
||||
|
||||
void viewer_open(void *parent, int id)
|
||||
{
|
||||
Viewer *i = (Viewer *)viewer_routs[id].viewer->open(parent, viewer_routs[0].p, viewer_routs[id].title.c_str());
|
||||
Viewer *i = (Viewer *)viewer_routs[id].viewer->open(parent, viewer_routs[id].p, viewer_routs[id].title.c_str());
|
||||
if (i)
|
||||
viewer_windows.push_back(i);
|
||||
}
|
||||
@@ -71,6 +71,33 @@ void viewer_update(viewer_t *viewer, void *p)
|
||||
}
|
||||
}
|
||||
|
||||
void viewer_notify_pause()
|
||||
{
|
||||
for (std::list<Viewer *>::iterator it = viewer_windows.begin(); it != viewer_windows.end(); it++)
|
||||
{
|
||||
(*it)->NotifyPause();
|
||||
}
|
||||
}
|
||||
|
||||
void viewer_notify_resume()
|
||||
{
|
||||
for (std::list<Viewer *>::iterator it = viewer_windows.begin(); it != viewer_windows.end(); it++)
|
||||
{
|
||||
(*it)->NotifyResume();
|
||||
}
|
||||
}
|
||||
|
||||
void viewer_call(viewer_t *viewer, void *p, void (*func)(void *v, void *param), void *param)
|
||||
{
|
||||
for (std::list<Viewer *>::iterator it = viewer_windows.begin(); it != viewer_windows.end(); it++)
|
||||
{
|
||||
if ((*it)->p == p)
|
||||
{
|
||||
func(*it, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_viewers_menu(void *menu)
|
||||
{
|
||||
wxMenuItem *m = ((wxMenu *)menu)->FindItem(XRCID("IDM_VIEW"));
|
||||
|
1088
src/wx-ui/viewers/viewer_voodoo.cc
Normal file
1088
src/wx-ui/viewers/viewer_voodoo.cc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,5 +8,6 @@ set(PCEM_SRC ${PCEM_SRC}
|
||||
wx-ui/viewers/viewer.cc
|
||||
wx-ui/viewers/viewer_font.cc
|
||||
wx-ui/viewers/viewer_palette.cc
|
||||
wx-ui/viewers/viewer_voodoo.cc
|
||||
wx-ui/viewers/viewer_vram.cc
|
||||
)
|
||||
|
@@ -524,6 +524,7 @@ int resume_emulation() {
|
||||
if (emulation_state == EMULATION_PAUSED) {
|
||||
emulation_state = EMULATION_RUNNING;
|
||||
pause = 0;
|
||||
viewer_notify_resume();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -591,6 +592,7 @@ int pause_emulation() {
|
||||
pclog("Emulation paused.\n");
|
||||
emulation_state = EMULATION_PAUSED;
|
||||
pause = 1;
|
||||
viewer_notify_pause();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user