Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelthegreat committed Mar 2, 2024
1 parent 2fe2dd1 commit d432a42
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 46 deletions.
2 changes: 1 addition & 1 deletion externals/cryptopp-cmake
2 changes: 1 addition & 1 deletion externals/dynarmic
2 changes: 1 addition & 1 deletion externals/oaknut
Submodule oaknut updated 29 files
+4 −172 .github/workflows/build-and-test.yml
+6 −41 CMakeLists.txt
+2 −152 README.md
+10 −10 include/oaknut/code_block.hpp
+0 −165 include/oaknut/dual_code_block.hpp
+0 −107 include/oaknut/feature_detection/cpu_feature.hpp
+0 −35 include/oaknut/feature_detection/feature_detection.hpp
+0 −112 include/oaknut/feature_detection/feature_detection_apple.hpp
+0 −62 include/oaknut/feature_detection/feature_detection_freebsd.hpp
+0 −23 include/oaknut/feature_detection/feature_detection_generic.hpp
+0 −120 include/oaknut/feature_detection/feature_detection_hwcaps.hpp
+0 −167 include/oaknut/feature_detection/feature_detection_idregs.hpp
+0 −45 include/oaknut/feature_detection/feature_detection_linux.hpp
+0 −81 include/oaknut/feature_detection/feature_detection_netbsd.hpp
+0 −63 include/oaknut/feature_detection/feature_detection_openbsd.hpp
+0 −99 include/oaknut/feature_detection/feature_detection_w32.hpp
+0 −318 include/oaknut/feature_detection/id_registers.hpp
+0 −52 include/oaknut/feature_detection/read_id_registers_directly.hpp
+22 −15 include/oaknut/impl/arm64_encode_helpers.inc.hpp
+0 −78 include/oaknut/impl/cpu_feature.inc.hpp
+5 −57 include/oaknut/impl/enum.hpp
+1 −7 include/oaknut/impl/offset.hpp
+6 −6 include/oaknut/impl/reg.hpp
+57 −84 include/oaknut/oaknut.hpp
+0 −5 oaknutConfig.cmake.in
+0 −77 tests/_feature_detect.cpp
+0 −6 tests/architecture.hpp
+20 −147 tests/basic.cpp
+3 −9 tests/vector_code_gen.cpp
2 changes: 1 addition & 1 deletion externals/teakra
Submodule teakra updated 77 files
+6 −0 .gitignore
+6 −0 .gitmodules
+1 −2 CMakeLists.txt
+7 −0 externals/CMakeLists.txt
+1 −0 externals/mcl
+1 −0 externals/xbyak
+1 −1 hwtest/dspapbptester/Makefile
+2 −2 hwtest/dspapbptester/source/main.cpp
+1 −1 hwtest/dspmemorytester/Makefile
+ hwtest/dspmemorytester/dspmemorytester.smdh
+2 −2 hwtest/dspmemorytester/source/main.cpp
+1 −1 hwtest/dsptester/Makefile
+3 −3 hwtest/dsptester/source/main.cpp
+1 −1 hwtest/dspvictester/Makefile
+2 −2 hwtest/dspvictester/source/main.cpp
+5 −0 include/teakra/teakra.h
+22 −1 src/CMakeLists.txt
+200 −0 src/bit_field.h
+2 −2 src/btdmp.cpp
+1 −1 src/btdmp.h
+340 −0 src/cityhash.cpp
+111 −0 src/cityhash.h
+3 −3 src/core_timing.h
+5 −0 src/crash.h
+6 −0 src/decoder.h
+2 −2 src/disassembler.cpp
+86 −0 src/hash.h
+193 −46 src/interpreter.h
+239 −0 src/ir/basic_block.cpp
+195 −0 src/ir/basic_block.h
+109 −0 src/ir/ir_emitter.cpp
+58 −0 src/ir/ir_emitter.h
+1 −0 src/ir/microinstruction.cpp
+39 −0 src/ir/microinstruction.h
+31 −0 src/ir/opcode.h
+0 −0 src/ir/value.cpp
+133 −0 src/ir/value.h
+0 −0 src/jit.cpp
+360 −0 src/jit.h
+1 −0 src/jit_no_ir.cpp
+5,278 −0 src/jit_no_ir.h
+881 −0 src/jit_regs.h
+12 −1 src/matcher.h
+1 −1 src/memory_interface.cpp
+1 −0 src/memory_interface.h
+43 −0 src/memory_pool.cpp
+45 −0 src/memory_pool.h
+2 −2 src/operand.h
+35 −11 src/processor.cpp
+4 −3 src/processor.h
+8 −7 src/register.h
+680 −0 src/swap.h
+38 −8 src/teakra.cpp
+2 −2 src/test.h
+1 −0 src/test_generator.cpp
+1 −1 src/test_verifier/CMakeLists.txt
+139 −40 src/test_verifier/main.cpp
+14 −7 src/timer.cpp
+1 −1 src/timer.h
+2 −0 src/translate/translate.cpp
+2,458 −0 src/translate/translate.h
+269 −0 src/xbyak_abi.h
+14 −4 tests/CMakeLists.txt
+276 −0 tests/audio.cpp
+53 −0 tests/audio.h
+41 −0 tests/audio_types.h
+193 −0 tests/bit_field.h
+5 −5 tests/btdmp.cpp
+66 −0 tests/common_funcs.h
+574 −0 tests/dsp.h
+107 −0 tests/dsp1.h
+320 −0 tests/firmware.cpp
+2 −2 tests/interpreter.cpp
+349 −0 tests/lle.h
+338 −1 tests/main.cpp
+617 −0 tests/swap.h
+16 −16 tests/timer.cpp
1 change: 1 addition & 0 deletions externals/teakra_interp
Submodule teakra_interp added at 01db7c
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/renderer_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void RendererVulkan::PrepareRendertarget() {

void RendererVulkan::PrepareDraw(Frame* frame, const Layout::FramebufferLayout& layout) {
const auto sampler = present_samplers[!Settings::values.filter_mode.GetValue()];
const auto present_set = present_heap.Commit();
const auto [present_set, _] = present_heap.Commit();
for (u32 index = 0; index < screen_infos.size(); index++) {
update_queue.AddImageSampler(present_set, 0, index, screen_infos[index].image_view,
sampler);
Expand Down
6 changes: 3 additions & 3 deletions src/video_core/renderer_vulkan/vk_blit_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ bool BlitHelper::BlitDepthStencil(Surface& source, Surface& dest,
.extent = {dest.GetScaledWidth(), dest.GetScaledHeight()},
};

const auto descriptor_set = two_textures_provider.Commit();
const auto [descriptor_set, _] = two_textures_provider.Commit();
update_queue.AddImageSampler(descriptor_set, 0, 0, source.DepthView(), nearest_sampler);
update_queue.AddImageSampler(descriptor_set, 1, 0, source.StencilView(), nearest_sampler);

Expand All @@ -309,7 +309,7 @@ bool BlitHelper::BlitDepthStencil(Surface& source, Surface& dest,

bool BlitHelper::ConvertDS24S8ToRGBA8(Surface& source, Surface& dest,
const VideoCore::TextureCopy& copy) {
const auto descriptor_set = compute_provider.Commit();
const auto [descriptor_set, _] = compute_provider.Commit();
update_queue.AddImageSampler(descriptor_set, 0, 0, source.DepthView(), VK_NULL_HANDLE,
vk::ImageLayout::eDepthStencilReadOnlyOptimal);
update_queue.AddImageSampler(descriptor_set, 1, 0, source.StencilView(), VK_NULL_HANDLE,
Expand Down Expand Up @@ -420,7 +420,7 @@ bool BlitHelper::ConvertDS24S8ToRGBA8(Surface& source, Surface& dest,

bool BlitHelper::DepthToBuffer(Surface& source, vk::Buffer buffer,
const VideoCore::BufferTextureCopy& copy) {
const auto descriptor_set = compute_buffer_provider.Commit();
const auto [descriptor_set, _] = compute_buffer_provider.Commit();
update_queue.AddImageSampler(descriptor_set, 0, 0, source.DepthView(), nearest_sampler,
vk::ImageLayout::eDepthStencilReadOnlyOptimal);
update_queue.AddImageSampler(descriptor_set, 1, 0, source.StencilView(), nearest_sampler,
Expand Down
6 changes: 3 additions & 3 deletions src/video_core/renderer_vulkan/vk_pipeline_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class PipelineCache {
~PipelineCache();

/// Acquires and binds a free descriptor set from the appropriate heap.
vk::DescriptorSet Acquire(DescriptorHeapType type) {
vk::DescriptorSet Acquire(DescriptorHeapType type, std::size_t hash = 0) {
const u32 index = static_cast<u32>(type);
const auto descriptor_set = descriptor_heaps[index].Commit();
const auto [descriptor_set, requires_update] = descriptor_heaps[index].Commit(hash);
bound_descriptor_sets[index] = descriptor_set;
return descriptor_set;
return requires_update ? descriptor_set : VK_NULL_HANDLE;
}

/// Sets the dynamic offset for the uniform buffer at binding
Expand Down
68 changes: 41 additions & 27 deletions src/video_core/renderer_vulkan/vk_rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,20 +559,17 @@ void RasterizerVulkan::SyncTextureUnits(const Framebuffer* framebuffer) {
using TextureType = Pica::TexturingRegs::TextureConfig::TextureType;

const auto pica_textures = regs.texturing.GetTextures();
const bool use_cube_heap =
pica_textures[0].enabled && pica_textures[0].config.type == TextureType::ShadowCube;
const auto texture_set = pipeline_cache.Acquire(use_cube_heap ? DescriptorHeapType::Texture
: DescriptorHeapType::Texture);

for (u32 texture_index = 0; texture_index < pica_textures.size(); ++texture_index) {
const auto& texture = pica_textures[texture_index];

// If the texture unit is disabled bind a null surface to it
if (!texture.enabled) {
const Surface& null_surface = res_cache.GetSurface(VideoCore::NULL_SURFACE_ID);
const Sampler& null_sampler = res_cache.GetSampler(VideoCore::NULL_SAMPLER_ID);
update_queue.AddImageSampler(texture_set, texture_index, 0, null_surface.ImageView(),
null_sampler.Handle());
images[texture_index] = {
.sampler = null_sampler.Handle(),
.imageView = null_surface.ImageView(),
};
continue;
}

Expand All @@ -583,16 +580,18 @@ void RasterizerVulkan::SyncTextureUnits(const Framebuffer* framebuffer) {
Surface& surface = res_cache.GetTextureSurface(texture);
Sampler& sampler = res_cache.GetSampler(texture.config);
surface.flags |= VideoCore::SurfaceFlagBits::ShadowMap;
update_queue.AddImageSampler(texture_set, texture_index, 0, surface.StorageView(),
sampler.Handle());
images[texture_index] = {
.sampler = sampler.Handle(),
.imageView = surface.StorageView(),
};
continue;
}
case TextureType::ShadowCube: {
BindShadowCube(texture, texture_set);
BindShadowCube(texture);
continue;
}
case TextureType::TextureCube: {
BindTextureCube(texture, texture_set);
BindTextureCube(texture);
continue;
}
default:
Expand All @@ -607,7 +606,21 @@ void RasterizerVulkan::SyncTextureUnits(const Framebuffer* framebuffer) {
const bool is_feedback_loop = color_view == surface.ImageView();
const vk::ImageView texture_view =
is_feedback_loop ? surface.CopyImageView() : surface.ImageView();
update_queue.AddImageSampler(texture_set, texture_index, 0, texture_view, sampler.Handle());
images[texture_index] = {
.sampler = sampler.Handle(),
.imageView = texture_view,
};
}

const std::size_t hash = Common::ComputeStructHash64(images);
const auto texture_set = pipeline_cache.Acquire(DescriptorHeapType::Texture, hash);
if (!texture_set) {
return;
}

for (u32 texture_index = 0; texture_index < pica_textures.size(); texture_index++) {
update_queue.AddImageSampler(texture_set, texture_index, 0,
images[texture_index].imageView, images[texture_index].sampler);
}
}

Expand All @@ -621,16 +634,15 @@ void RasterizerVulkan::SyncUtilityTextures(const Framebuffer* framebuffer) {
update_queue.AddStorageImage(utility_set, 0, framebuffer->ImageView(SurfaceType::Color));
}

void RasterizerVulkan::BindShadowCube(const Pica::TexturingRegs::FullTextureConfig& texture,
vk::DescriptorSet texture_set) {
using CubeFace = Pica::TexturingRegs::CubeFace;
auto info = Pica::Texture::TextureInfo::FromPicaRegister(texture.config, texture.format);
constexpr std::array faces = {
CubeFace::PositiveX, CubeFace::NegativeX, CubeFace::PositiveY,
CubeFace::NegativeY, CubeFace::PositiveZ, CubeFace::NegativeZ,
};
void RasterizerVulkan::BindShadowCube(const Pica::TexturingRegs::FullTextureConfig& texture) {
//using CubeFace = Pica::TexturingRegs::CubeFace;
//auto info = Pica::Texture::TextureInfo::FromPicaRegister(texture.config, texture.format);
//constexpr std::array faces = {
// CubeFace::PositiveX, CubeFace::NegativeX, CubeFace::PositiveY,
// CubeFace::NegativeY, CubeFace::PositiveZ, CubeFace::NegativeZ,
//};

Sampler& sampler = res_cache.GetSampler(texture.config);
/*Sampler& sampler = res_cache.GetSampler(texture.config);
for (CubeFace face : faces) {
const u32 binding = static_cast<u32>(face);
Expand All @@ -639,13 +651,12 @@ void RasterizerVulkan::BindShadowCube(const Pica::TexturingRegs::FullTextureConf
const VideoCore::SurfaceId surface_id = res_cache.GetTextureSurface(info);
Surface& surface = res_cache.GetSurface(surface_id);
surface.flags |= VideoCore::SurfaceFlagBits::ShadowMap;
update_queue.AddImageSampler(texture_set, 0, binding, surface.StorageView(),
sampler.Handle());
}
//update_queue.AddImageSampler(texture_set, 0, binding, surface.StorageView(),
// sampler.Handle());
}*/
}

void RasterizerVulkan::BindTextureCube(const Pica::TexturingRegs::FullTextureConfig& texture,
vk::DescriptorSet texture_set) {
void RasterizerVulkan::BindTextureCube(const Pica::TexturingRegs::FullTextureConfig& texture) {
using CubeFace = Pica::TexturingRegs::CubeFace;
const VideoCore::TextureCubeConfig config = {
.px = regs.texturing.GetCubePhysicalAddress(CubeFace::PositiveX),
Expand All @@ -661,7 +672,10 @@ void RasterizerVulkan::BindTextureCube(const Pica::TexturingRegs::FullTextureCon

Surface& surface = res_cache.GetTextureCube(config);
Sampler& sampler = res_cache.GetSampler(texture.config);
update_queue.AddImageSampler(texture_set, 0, 0, surface.ImageView(), sampler.Handle());
images[0] = {
.sampler = sampler.Handle(),
.imageView = surface.ImageView(),
};
}

void RasterizerVulkan::NotifyFixedFunctionPicaRegisterChanged(u32 id) {
Expand Down
7 changes: 3 additions & 4 deletions src/video_core/renderer_vulkan/vk_rasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ class RasterizerVulkan : public VideoCore::RasterizerAccelerated {
void SyncUtilityTextures(const Framebuffer* framebuffer);

/// Binds the PICA shadow cube required for shadow mapping
void BindShadowCube(const Pica::TexturingRegs::FullTextureConfig& texture,
vk::DescriptorSet texture_set);
void BindShadowCube(const Pica::TexturingRegs::FullTextureConfig& texture);

/// Binds a texture cube to texture unit 0
void BindTextureCube(const Pica::TexturingRegs::FullTextureConfig& texture,
vk::DescriptorSet texture_set);
void BindTextureCube(const Pica::TexturingRegs::FullTextureConfig& texture);

/// Upload the uniform blocks to the uniform buffer object
void UploadUniforms(bool accelerate_draw);
Expand Down Expand Up @@ -154,6 +152,7 @@ class RasterizerVulkan : public VideoCore::RasterizerAccelerated {
std::array<u32, 16> binding_offsets{};
std::array<bool, 16> enable_attributes{};
std::array<vk::Buffer, 16> vertex_buffers;
std::array<vk::DescriptorImageInfo, 3> images{};
VertexArrayInfo vertex_info;
PipelineInfo pipeline_info{};

Expand Down
23 changes: 21 additions & 2 deletions src/video_core/renderer_vulkan/vk_resource_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ DescriptorHeap::~DescriptorHeap() = default;
void DescriptorHeap::Allocate(std::size_t begin, std::size_t end) {
ASSERT(end - begin == DESCRIPTOR_SET_BATCH);
descriptor_sets.resize(end);
hashes.resize(end);

std::array<vk::DescriptorSetLayout, DESCRIPTOR_SET_BATCH> layouts;
layouts.fill(*descriptor_set_layout);
Expand Down Expand Up @@ -170,9 +171,27 @@ void DescriptorHeap::Allocate(std::size_t begin, std::size_t end) {
}
}

vk::DescriptorSet DescriptorHeap::Commit() {
std::pair<vk::DescriptorSet, bool> DescriptorHeap::Commit(std::size_t hash) {
if (hash == 0) {
const std::size_t index = CommitResource();
return {descriptor_sets[index], true};
}

// Try to recycle an existing descriptor set that matches the content hash.
const auto it = descriptor_content_map.find(hash);
if (it != descriptor_content_map.end()) {
ticks[it->second] = master_semaphore->CurrentTick();
return {descriptor_sets[it->second], false};
}

// No descriptor set found, provide a fresh one
const std::size_t index = CommitResource();
return descriptor_sets[index];
if (hashes[index] != 0) {
descriptor_content_map.erase(hashes[index]);
}
descriptor_content_map[hash] = index;
hashes[index] = hash;
return {descriptor_sets[index], true};
}

void DescriptorHeap::AppendDescriptorPool() {
Expand Down
6 changes: 5 additions & 1 deletion src/video_core/renderer_vulkan/vk_resource_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#pragma once

#include <vector>
#include <tsl/robin_map.h>

#include "common/common_types.h"
#include "video_core/renderer_vulkan/vk_common.h"

Expand Down Expand Up @@ -74,7 +76,7 @@ class DescriptorHeap final : public ResourcePool {

void Allocate(std::size_t begin, std::size_t end) override;

vk::DescriptorSet Commit();
std::pair<vk::DescriptorSet, bool> Commit(std::size_t hash = 0);

private:
void AppendDescriptorPool();
Expand All @@ -86,6 +88,8 @@ class DescriptorHeap final : public ResourcePool {
std::vector<vk::DescriptorPoolSize> pool_sizes;
std::vector<vk::UniqueDescriptorPool> pools;
std::vector<vk::DescriptorSet> descriptor_sets;
std::vector<std::size_t> hashes;
tsl::robin_map<std::size_t, std::size_t> descriptor_content_map;
};

} // namespace Vulkan

0 comments on commit d432a42

Please sign in to comment.