Merge remote-tracking branch 'upstream/master' into feature/ich2

This commit is contained in:
Jasmine Iwanek
2022-11-03 23:28:16 -04:00
8 changed files with 186 additions and 29 deletions

View File

@@ -33,7 +33,8 @@ static const uint32_t texture_offset[LOD_MAX + 3] = {
256 * 256 + 128 * 128 + 64 * 64 + 32 * 32 + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2 + 1 * 1 + 1
};
void voodoo_recalc_tex(voodoo_t *voodoo, int tmu);
void voodoo_recalc_tex12(voodoo_t *voodoo, int tmu);
void voodoo_recalc_tex3(voodoo_t *voodoo, int tmu);
void voodoo_use_texture(voodoo_t *voodoo, voodoo_params_t *params, int tmu);
void voodoo_tex_writel(uint32_t addr, uint32_t val, void *p);
void flush_texture_cache(voodoo_t *voodoo, uint32_t dirty_addr, int tmu);

View File

@@ -140,7 +140,8 @@ void HardwareRenderer::initializeGL()
pclog("OpenGL shader language version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
glClearColor(0, 0, 0, 1);
m_texture->setWrapMode(QOpenGLTexture::ClampToEdge);
update();
glClear(GL_COLOR_BUFFER_BIT);
m_context->swapBuffers(this);
}
void HardwareRenderer::paintGL() {

View File

@@ -75,6 +75,7 @@ public:
m_context = new QOpenGLContext();
m_context->setFormat(format());
m_context->create();
update();
}
~HardwareRenderer()
{

View File

@@ -75,6 +75,10 @@ extern "C" {
#include <QScreen>
#include <QString>
#include <QDir>
#if QT_CONFIG(vulkan)
#include <QVulkanInstance>
#include <QVulkanFunctions>
#endif
#include <array>
#include <unordered_map>
@@ -325,10 +329,25 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionVNC->setVisible(false);
#endif
#if !QT_CONFIG(vulkan)
if (vid_api == 4) vid_api = 0;
ui->actionVulkan->setVisible(false);
#if QT_CONFIG(vulkan)
bool vulkanAvailable = false;
{
QVulkanInstance instance;
instance.setApiVersion(QVersionNumber(1, 0));
if (instance.create()) {
uint32_t physicalDevices = 0;
instance.functions()->vkEnumeratePhysicalDevices(instance.vkInstance(), &physicalDevices, nullptr);
if (physicalDevices != 0) {
vulkanAvailable = true;
}
}
}
if (!vulkanAvailable)
#endif
{
if (vid_api == 4) vid_api = 0;
ui->actionVulkan->setVisible(false);
}
QActionGroup* actGroup = nullptr;

View File

@@ -795,18 +795,8 @@ VulkanWindowRenderer::VulkanWindowRenderer(QWidget* parent)
: QVulkanWindow(parent->windowHandle())
{
parentWidget = parent;
instance.setLayers(QByteArrayList() << "VK_LAYER_KHRONOS_validation");
instance.setExtensions(QByteArrayList() << "VK_EXT_debug_report");
instance.setApiVersion(QVersionNumber(1, 0));
if (!instance.create()) {
throw std::runtime_error("Could not create Vulkan instance");
}
uint32_t physicalDevices = 0;
instance.functions()->vkEnumeratePhysicalDevices(instance.vkInstance(), &physicalDevices, nullptr);
if (physicalDevices == 0) {
throw std::runtime_error("No physical devices available.");
}
qDebug() << instance.layers();
instance.create();
setVulkanInstance(&instance);
setPhysicalDeviceIndex(0);
setPreferredColorFormats({VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_A8B8G8R8_UNORM_PACK32});

View File

@@ -98,6 +98,12 @@ typedef struct banshee_t {
uint32_t vidScreenSize;
uint32_t vidSerialParallelPort;
uint32_t agpReqSize;
uint32_t agpHostAddressHigh;
uint32_t agpHostAddressLow;
uint32_t agpGraphicsAddress;
uint32_t agpGraphicsStride;
int overlay_pix_fmt;
uint32_t hwCurPatAddr, hwCurLoc, hwCurC0, hwCurC1;
@@ -161,19 +167,25 @@ enum {
Video_vidOverlayDvdy = 0xac,
Video_vidOverlayDvdyOffset = 0xe0,
Video_vidDesktopStartAddr = 0xe4,
Video_vidDesktopOverlayStride = 0xe8
Video_vidDesktopOverlayStride = 0xe8,
};
enum {
cmdBaseAddr0 = 0x20,
cmdBaseSize0 = 0x24,
cmdBump0 = 0x28,
cmdRdPtrL0 = 0x2c,
cmdRdPtrH0 = 0x30,
cmdAMin0 = 0x34,
cmdAMax0 = 0x3c,
cmdFifoDepth0 = 0x44,
cmdHoleCnt0 = 0x48
cmdBaseAddr0 = 0x20,
cmdBaseSize0 = 0x24,
cmdBump0 = 0x28,
cmdRdPtrL0 = 0x2c,
cmdRdPtrH0 = 0x30,
cmdAMin0 = 0x34,
cmdAMax0 = 0x3c,
cmdFifoDepth0 = 0x44,
cmdHoleCnt0 = 0x48,
Agp_agpReqSize = 0x00,
Agp_agpHostAddressLow = 0x04,
Agp_agpHostAddressHigh = 0x08,
Agp_agpGraphicsAddress = 0x0C,
Agp_agpGraphicsStride = 0x10,
};
#define VGAINIT0_EXTENDED_SHIFT_OUT (1 << 12)
@@ -1123,6 +1135,26 @@ banshee_cmd_read(banshee_t *banshee, uint32_t addr)
uint32_t ret = 0xffffffff;
switch (addr & 0x1fc) {
case Agp_agpHostAddressLow:
ret = banshee->agpHostAddressLow;
break;
case Agp_agpHostAddressHigh:
ret = banshee->agpHostAddressHigh;
break;
case Agp_agpGraphicsAddress:
ret = banshee->agpGraphicsAddress;
break;
case Agp_agpGraphicsStride:
ret = banshee->agpGraphicsStride;
break;
case Agp_agpReqSize:
ret = banshee->agpReqSize;
break;
case cmdBaseAddr0:
ret = voodoo->cmdfifo_base >> 12;
// banshee_log("Read cmdfifo_base %08x\n", ret);
@@ -1142,7 +1174,7 @@ banshee_cmd_read(banshee_t *banshee, uint32_t addr)
break;
default:
fatal("Unknown banshee_cmd_read %08x\n", addr);
fatal("Unknown banshee_cmd_read 0x%08x (reg 0x%03x)\n", addr, addr & 0x1fc);
}
return ret;
@@ -1348,6 +1380,26 @@ banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val)
voodoo_t *voodoo = banshee->voodoo;
// banshee_log("banshee_cmd_write: addr=%03x val=%08x\n", addr & 0x1fc, val);
switch (addr & 0x1fc) {
case Agp_agpHostAddressLow:
banshee->agpHostAddressLow = val;
break;
case Agp_agpHostAddressHigh:
banshee->agpHostAddressHigh = val;
break;
case Agp_agpGraphicsAddress:
banshee->agpGraphicsAddress = val;
break;
case Agp_agpGraphicsStride:
banshee->agpGraphicsStride = val;
break;
case Agp_agpReqSize:
banshee->agpReqSize = val;
break;
case cmdBaseAddr0:
voodoo->cmdfifo_base = (val & 0xfff) << 12;
voodoo->cmdfifo_end = voodoo->cmdfifo_base + (((voodoo->cmdfifo_size & 0xff) + 1) << 12);
@@ -1382,7 +1434,7 @@ banshee_cmd_write(banshee_t *banshee, uint32_t addr, uint32_t val)
break;
default:
banshee_log("Unknown banshee_cmd_write: addr=%08x val=%08x\n", addr, val);
banshee_log("Unknown banshee_cmd_write: addr=%08x val=%08x reg=0x%03x\n", addr, val, addr & 0x1fc);
break;
}

View File

@@ -73,6 +73,7 @@ void
voodoo_reg_writel(uint32_t addr, uint32_t val, void *p)
{
voodoo_t *voodoo = (voodoo_t *) p;
void (*voodoo_recalc_tex)(voodoo_t *voodoo, int tmu) = NULL;
union {
uint32_t i;
float f;
@@ -82,6 +83,11 @@ voodoo_reg_writel(uint32_t addr, uint32_t val, void *p)
if (!chip)
chip = 0xf;
if (voodoo->type == VOODOO_3)
voodoo_recalc_tex = voodoo_recalc_tex3;
else
voodoo_recalc_tex = voodoo_recalc_tex12;
tempif.i = val;
// voodoo_reg_log("voodoo_reg_write_l: addr=%08x val=%08x(%f) chip=%x\n", addr, val, tempif.f, chip);
addr &= 0x3fc;

View File

@@ -59,7 +59,94 @@ voodoo_texture_log(const char *fmt, ...)
#endif
void
voodoo_recalc_tex(voodoo_t *voodoo, int tmu)
voodoo_recalc_tex12(voodoo_t *voodoo, int tmu)
{
int aspect = (voodoo->params.tLOD[tmu] >> 21) & 3;
int width = 256, height = 256;
int shift = 8;
int lod;
uint32_t base = voodoo->params.texBaseAddr[tmu];
uint32_t offset = 0;
int tex_lod = 0;
if (voodoo->params.tLOD[tmu] & LOD_S_IS_WIDER)
height >>= aspect;
else {
width >>= aspect;
shift -= aspect;
}
if ((voodoo->params.tLOD[tmu] & LOD_SPLIT) && (voodoo->params.tLOD[tmu] & LOD_ODD)) {
width >>= 1;
height >>= 1;
shift--;
tex_lod++;
if (voodoo->params.tLOD[tmu] & LOD_TMULTIBASEADDR)
base = voodoo->params.texBaseAddr1[tmu];
}
for (lod = 0; lod <= LOD_MAX + 1; lod++) {
if (!width)
width = 1;
if (!height)
height = 1;
if (shift < 0)
shift = 0;
voodoo->params.tex_base[tmu][lod] = base + offset;
if (voodoo->params.tformat[tmu] & 8)
voodoo->params.tex_end[tmu][lod] = base + offset + (width * height * 2);
else
voodoo->params.tex_end[tmu][lod] = base + offset + (width * height);
voodoo->params.tex_w_mask[tmu][lod] = width - 1;
voodoo->params.tex_w_nmask[tmu][lod] = ~(width - 1);
voodoo->params.tex_h_mask[tmu][lod] = height - 1;
voodoo->params.tex_shift[tmu][lod] = shift;
voodoo->params.tex_lod[tmu][lod] = tex_lod;
if (!(voodoo->params.tLOD[tmu] & LOD_SPLIT) || ((lod & 1) && (voodoo->params.tLOD[tmu] & LOD_ODD)) || (!(lod & 1) && !(voodoo->params.tLOD[tmu] & LOD_ODD))) {
if (!(voodoo->params.tLOD[tmu] & LOD_ODD) || lod != 0) {
if (voodoo->params.tformat[tmu] & 8)
offset += width * height * 2;
else
offset += width * height;
if (voodoo->params.tLOD[tmu] & LOD_SPLIT) {
width >>= 2;
height >>= 2;
shift -= 2;
tex_lod += 2;
} else {
width >>= 1;
height >>= 1;
shift--;
tex_lod++;
}
if (voodoo->params.tLOD[tmu] & LOD_TMULTIBASEADDR) {
switch (tex_lod) {
case 0:
base = voodoo->params.texBaseAddr[tmu];
break;
case 1:
base = voodoo->params.texBaseAddr1[tmu];
break;
case 2:
base = voodoo->params.texBaseAddr2[tmu];
break;
default:
base = voodoo->params.texBaseAddr38[tmu];
break;
}
}
}
}
}
voodoo->params.tex_width[tmu] = width;
}
void
voodoo_recalc_tex3(voodoo_t *voodoo, int tmu)
{
int aspect = (voodoo->params.tLOD[tmu] >> 21) & 3;
int width = 256, height = 256;