Merge branch 'master' into vulkan

This commit is contained in:
Triang3l 2021-06-19 13:58:50 +03:00
commit 0ebb3bd90e
3 changed files with 34 additions and 18 deletions

View File

@ -2,41 +2,51 @@
****************************************************************************** ******************************************************************************
* Xenia : Xbox 360 Emulator Research Project * * Xenia : Xbox 360 Emulator Research Project *
****************************************************************************** ******************************************************************************
* Copyright 2019 Ben Vanik. All rights reserved. * * Copyright 2021 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. * * Released under the BSD license - see LICENSE in the root for more details. *
****************************************************************************** ******************************************************************************
*/ */
#include "xenia/base/clock.h"
#include <sys/time.h> #include <sys/time.h>
#include <time.h>
#include "xenia/base/assert.h"
#include "xenia/base/clock.h"
namespace xe { namespace xe {
uint64_t Clock::host_tick_frequency_platform() { uint64_t Clock::host_tick_frequency_platform() {
timespec res; timespec res;
clock_getres(CLOCK_MONOTONIC_RAW, &res); int error = clock_getres(CLOCK_MONOTONIC_RAW, &res);
assert_zero(error);
assert_zero(res.tv_sec); // Sub second resolution is required.
return uint64_t(res.tv_sec) + uint64_t(res.tv_nsec) * 1000000000ull; // Convert nano seconds to hertz. Resolution is 1ns on most systems.
return 1000000000ull / res.tv_nsec;
} }
uint64_t Clock::host_tick_count_platform() { uint64_t Clock::host_tick_count_platform() {
timespec res; timespec tp;
clock_gettime(CLOCK_MONOTONIC_RAW, &res); int error = clock_gettime(CLOCK_MONOTONIC_RAW, &tp);
assert_zero(error);
return uint64_t(res.tv_sec) + uint64_t(res.tv_nsec) * 1000000000ull; return tp.tv_nsec + tp.tv_sec * 1000000000ull;
} }
uint64_t Clock::QueryHostSystemTime() { uint64_t Clock::QueryHostSystemTime() {
struct timeval tv; // https://docs.microsoft.com/en-us/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
gettimeofday(&tv, NULL); constexpr uint64_t seconds_per_day = 3600 * 24;
// Don't forget the 89 leap days.
constexpr uint64_t seconds_1601_to_1970 =
((369 * 365 + 89) * seconds_per_day);
uint64_t ret = tv.tv_usec; timeval now;
ret /= 1000; // usec -> msec int error = gettimeofday(&now, nullptr);
assert_zero(error);
ret += (tv.tv_sec * 1000); // sec -> msec // NT systems use 100ns intervals.
return ret; return static_cast<uint64_t>(
(static_cast<int64_t>(now.tv_sec) + seconds_1601_to_1970) * 10000000ull +
now.tv_usec * 10);
} }
uint64_t Clock::QueryHostUptimeMillis() { uint64_t Clock::QueryHostUptimeMillis() {

View File

@ -845,7 +845,9 @@ RenderTargetCache::GetConfigDepthFloat24Conversion() {
uint32_t RenderTargetCache::GetRenderTargetHeight( uint32_t RenderTargetCache::GetRenderTargetHeight(
uint32_t pitch_tiles_at_32bpp, xenos::MsaaSamples msaa_samples) const { uint32_t pitch_tiles_at_32bpp, xenos::MsaaSamples msaa_samples) const {
assert_not_zero(pitch_tiles_at_32bpp); if (!pitch_tiles_at_32bpp) {
return 0;
}
// Down to the end of EDRAM. // Down to the end of EDRAM.
uint32_t tile_rows = (xenos::kEdramTileCount + (pitch_tiles_at_32bpp - 1)) / uint32_t tile_rows = (xenos::kEdramTileCount + (pitch_tiles_at_32bpp - 1)) /
pitch_tiles_at_32bpp; pitch_tiles_at_32bpp;

View File

@ -265,11 +265,15 @@ class RenderTargetCache {
uint32_t GetPitchTiles() const { uint32_t GetPitchTiles() const {
return pitch_tiles_at_32bpp << uint32_t(Is64bpp()); return pitch_tiles_at_32bpp << uint32_t(Is64bpp());
} }
uint32_t GetWidth() const { static constexpr uint32_t GetWidth(uint32_t pitch_tiles_at_32bpp,
xenos::MsaaSamples msaa_samples) {
return pitch_tiles_at_32bpp * return pitch_tiles_at_32bpp *
(xenos::kEdramTileWidthSamples >> (xenos::kEdramTileWidthSamples >>
uint32_t(msaa_samples >= xenos::MsaaSamples::k4X)); uint32_t(msaa_samples >= xenos::MsaaSamples::k4X));
} }
uint32_t GetWidth() const {
return GetWidth(pitch_tiles_at_32bpp, msaa_samples);
}
std::string GetDebugName() const { std::string GetDebugName() const {
return fmt::format( return fmt::format(