mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 10:28:19 -07:00
hash lookup fixes
This commit is contained in:
@@ -1446,6 +1446,8 @@ void nv3_pgraph_init();
|
||||
uint32_t nv3_pgraph_read(uint32_t address);
|
||||
void nv3_pgraph_write(uint32_t address, uint32_t value);
|
||||
void nv3_pgraph_vblank_start(svga_t* svga);
|
||||
void nv3_pgraph_submit(uint8_t name, uint16_t method, uint8_t channel, uint8_t subchannel, uint8_t class_id, uint32_t context);
|
||||
|
||||
|
||||
// NV3 PFIFO
|
||||
void nv3_pfifo_init();
|
||||
|
||||
@@ -680,14 +680,14 @@ void nv3_pfifo_cache1_pull()
|
||||
if (nv3->pfifo.cache1_settings.put_address == nv3->pfifo.cache1_settings.get_address)
|
||||
return;
|
||||
|
||||
uint32_t get_address = nv3->pfifo.cache1_settings.get_address >> 2; // 32 bit aligned probably
|
||||
uint32_t get_index = nv3->pfifo.cache1_settings.get_address >> 2; // 32 bit aligned probably
|
||||
|
||||
uint8_t current_channel = nv3->pfifo.cache1_settings.channel;
|
||||
uint8_t current_subchannel = nv3->pfifo.cache1_entries[get_address].subchannel;
|
||||
uint32_t current_name = nv3->pfifo.cache1_entries[get_address].data;
|
||||
uint16_t current_method = nv3->pfifo.cache1_entries[get_address].method;
|
||||
uint8_t current_subchannel = nv3->pfifo.cache1_entries[get_index].subchannel;
|
||||
uint32_t current_name = nv3->pfifo.cache1_entries[get_index].data;
|
||||
uint16_t current_method = nv3->pfifo.cache1_entries[get_index].method;
|
||||
|
||||
// i.e. there is no method in cache1, so we have to find the object.
|
||||
// NV_ROOT
|
||||
if (!current_method)
|
||||
{
|
||||
if (!nv3_ramin_find_object(current_name, 0, current_channel, current_subchannel))
|
||||
@@ -707,7 +707,7 @@ void nv3_pfifo_cache1_pull()
|
||||
}
|
||||
|
||||
// start by incrementing
|
||||
uint32_t next_get_address = nv3_pfifo_cache1_gray2normal(get_address) + 1;
|
||||
uint32_t next_get_address = nv3_pfifo_cache1_gray2normal(get_index) + 1;
|
||||
|
||||
if (nv3->nvbase.gpu_revision >= NV3_BOOT_REG_REV_C00) // RIVA 128ZX#
|
||||
next_get_address &= (NV3_PFIFO_CACHE1_SIZE_REV_C - 1);
|
||||
|
||||
@@ -449,7 +449,7 @@ void nv3_pgraph_write(uint32_t address, uint32_t value)
|
||||
// Addresses should be aligned to 4 bytes.
|
||||
uint32_t entry = (address - NV3_PGRAPH_CONTEXT_CACHE(0));
|
||||
|
||||
nv_log("PGRAPH Context Cache Write (Entry=%04x Value=%04x)\n", entry, value);
|
||||
nv_log("PGRAPH Context Cache Write (Entry=%04x Value=0x%08x)\n", entry, value);
|
||||
nv3->pgraph.context_cache[entry] = value;
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ void nv3_pgraph_submit(uint8_t name, uint16_t method, uint8_t channel, uint8_t s
|
||||
{
|
||||
// This method is how we figure out which methods exist.
|
||||
case NV3_ROOT_HI_IM_OBJECT_MCOBJECTYFACE:
|
||||
nv_log("Hi, I'm an NV []");
|
||||
nv_log("Hi, I'm an NVidia object :)\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -352,13 +352,32 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint8_t channel, u
|
||||
// TODO: WRITE IT!!!
|
||||
// Set the number of entries to search based on the ramht size (2*(size+1))
|
||||
// Not a switch statement in case newer gpus have larger ramins
|
||||
uint32_t bucket_entries = 2 * (((nv3->pfifo.ramht_config >> NV3_PFIFO_CONFIG_RAMHT_SIZE) & 0x03) + 1);
|
||||
|
||||
uint32_t bucket_entries = 2;
|
||||
|
||||
switch (nv3->pfifo.ramht_config)
|
||||
{
|
||||
case NV3_PFIFO_CONFIG_RAMHT_SIZE_4K:
|
||||
// stays as is
|
||||
break;
|
||||
case NV3_PFIFO_CONFIG_RAMHT_SIZE_8K:
|
||||
bucket_entries = 4;
|
||||
break;
|
||||
case NV3_PFIFO_CONFIG_RAMHT_SIZE_16K:
|
||||
bucket_entries = 8;
|
||||
break;
|
||||
case NV3_PFIFO_CONFIG_RAMHT_SIZE_32K:
|
||||
bucket_entries = 16;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Calculate the address in the hashtable
|
||||
uint32_t ramht_base = ((nv3->pfifo.ramht_config >> NV3_PFIFO_CONFIG_RAMHT_BASE_ADDRESS) & 0x0F) << NV3_PFIFO_CONFIG_RAMHT_BASE_ADDRESS;
|
||||
uint32_t ramht_cur_address = ramht_base;
|
||||
uint32_t ramht_cur_address = ramht_base + (nv3_ramht_hash(name, channel)) * bucket_entries * 8;
|
||||
|
||||
nv_log("Beginning search for graphics object at RAMHT base=0x%04x, Cache%d, channel=%d, subchannel=%d)", name, cache_num, channel, subchannel);
|
||||
nv_log("Beginning search for graphics object at RAMHT base=0x%04x, name=0x%08x, Cache%d, channel=%d.%d)\n",
|
||||
ramht_cur_address, name, cache_num, channel, subchannel);
|
||||
|
||||
bool found_object = false;
|
||||
|
||||
@@ -385,19 +404,17 @@ bool nv3_ramin_find_object(uint32_t name, uint32_t cache_num, uint8_t channel, u
|
||||
|
||||
if (!found_object)
|
||||
{
|
||||
nv3->pfifo.debug_0 |= NV3_PFIFO_CACHE0_ERROR_PENDING;
|
||||
|
||||
if (!cache_num)
|
||||
{
|
||||
nv3->pfifo.debug_0 |= NV3_PFIFO_CACHE0_ERROR_PENDING;
|
||||
nv3->pfifo.cache0_settings.puller_control |= NV3_PFIFO_CACHE0_PULLER_CONTROL_HASH_FAILURE;
|
||||
|
||||
//It turns itself off on failure, the drivers turn it back on
|
||||
nv3->pfifo.cache0_settings.puller_control &= ~NV3_PFIFO_CACHE0_PULLER_CONTROL_ENABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
nv3->pfifo.debug_0 |= NV3_PFIFO_CACHE1_ERROR_PENDING;
|
||||
nv3->pfifo.cache1_settings.puller_control |= NV3_PFIFO_CACHE1_PULLER_CONTROL_HASH_FAILURE;
|
||||
|
||||
//It turns itself off on failure, the drivers turn it back on
|
||||
nv3->pfifo.cache1_settings.puller_control &= ~NV3_PFIFO_CACHE1_PULLER_CONTROL_ENABLED;
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ It is used to get the offset within RAMHT of a graphics object.
|
||||
uint32_t nv3_ramht_hash(uint32_t name, uint32_t channel)
|
||||
{
|
||||
// convert the name to an array of bytes
|
||||
uint8_t* hash_bytes = (uint8_t*)name;
|
||||
uint8_t* hash_bytes = (uint8_t*)&name;
|
||||
|
||||
// is this the right endianness?
|
||||
uint32_t hash = (hash_bytes[0] ^ hash_bytes[1] ^ hash_bytes[2] ^ hash_bytes[3] ^ (uint8_t)channel);
|
||||
nv_log("Generated RAMHT hash 0x%04x (RAMHT slot=0x%04x (from name 0x%08x for DMA channel 0x%04x)\n)\n", hash, name, channel);
|
||||
nv_log("Generated RAMHT hash 0x%04x (RAMHT slot=0x%04x (from name 0x%08x for DMA channel 0x%04x)\n)\n", hash, (hash/8), name, channel);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user