Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Dash Faction Changelog
Version 1.9.2 (not released yet)
--------------------------------
[@is-this-c](https://github.com/is-this-c)
- Fix Dash Faction Launcher's querying of MSAA levels in Direct3D 11
- Set `rf::gr::text_2d_mode` to ignore fog
- Fix `gr_d3d_bitmap`, so `gr_d3d_set_state` is called earlier
- Fix a potential crash, after a client quits a game, if Directd3D 11 is enabled
- Improve compatibility with Alpine Faction servers
- Fix `PgUp`, `PgDown`, `End`, and `Home` on numeric keypads
- Improve compatibility with Alpine Faction's network protocol
- Fix Num Pad `PgUp`, `PgDown`, `End`, and `Home`

Version 1.9.1 (released 2025-07-05)
--------------------------------
Expand Down
3 changes: 2 additions & 1 deletion game_patch/graphics/gr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,6 @@ void gr_apply_patch()
lod_distance_scale_cmd.register_cmd();

// Fix `rf::gr::text_2d_mode`.
AsmWriter{0x0050BB40}.push(static_cast<uint8_t>(rf::gr::FOG_NOT_ALLOWED));
constexpr uint8_t TEXT_FOG_TYPE = static_cast<uint8_t>(rf::gr::FOG_NOT_ALLOWED);
AsmWriter{0x0050BB40}.push(TEXT_FOG_TYPE);
}
41 changes: 29 additions & 12 deletions launcher_common/VideoDeviceInfoProviderD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VideoDeviceInfoProviderD3D11 : public VideoDeviceInfoProvider
~VideoDeviceInfoProviderD3D11() override = default;
std::vector<std::string> get_adapters() override;
std::set<Resolution> get_resolutions(unsigned adapter, unsigned format) override;
std::set<unsigned> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
std::set<uint32_t> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
bool has_anisotropy_support(unsigned adapter) override;

unsigned get_format_from_bpp(unsigned bpp) override
Expand Down Expand Up @@ -123,30 +123,47 @@ std::set<VideoDeviceInfoProvider::Resolution> VideoDeviceInfoProviderD3D11::get_
return result;
}

std::set<unsigned> VideoDeviceInfoProviderD3D11::get_multisample_types(
unsigned adapter, unsigned format, [[maybe_unused]] bool windowed
std::set<uint32_t> VideoDeviceInfoProviderD3D11::get_multisample_types(
const unsigned adapter,
const unsigned format,
[[maybe_unused]] const bool windowed
) {

ComPtr<IDXGIAdapter> dxgi_adapter;
ComPtr<IDXGIAdapter> dxgi_adapter{};
HRESULT hr = m_factory->EnumAdapters(adapter, &dxgi_adapter);
if (FAILED(hr)) {
xlog::error("EnumAdapters failed: {:x}", hr);
return {};
}

ComPtr<ID3D11Device> d3d11_device;
hr = m_D3D11CreateDevice(dxgi_adapter, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &d3d11_device, nullptr, nullptr);
ComPtr<ID3D11Device> d3d11_device{};
hr = m_D3D11CreateDevice(
dxgi_adapter,
D3D_DRIVER_TYPE_UNKNOWN,
nullptr,
0,
nullptr,
0,
D3D11_SDK_VERSION,
&d3d11_device,
nullptr,
nullptr
);
if (FAILED(hr)) {
xlog::error("D3D11CreateDevice failed: {:x}", hr);
return {};
}

std::set<unsigned> result;
for (unsigned i = 2; i <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; i *= 2) {
UINT quality_levels;
HRESULT hr = d3d11_device->CheckMultisampleQualityLevels(static_cast<DXGI_FORMAT>(format), i, &quality_levels);
if (SUCCEEDED(hr))
std::set<uint32_t> result{};
for (uint32_t i = 2; i <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; i <<= 1) {
UINT quality_levels = 0;
const HRESULT hr = d3d11_device->CheckMultisampleQualityLevels(
static_cast<DXGI_FORMAT>(format),
i,
&quality_levels
);
if (SUCCEEDED(hr) && quality_levels > 0) {
result.insert(i);
}
}
return result;
}
Expand Down
23 changes: 16 additions & 7 deletions launcher_common/VideoDeviceInfoProviderD3D8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VideoDeviceInfoProviderD3D8 : public VideoDeviceInfoProvider
~VideoDeviceInfoProviderD3D8() override = default;
std::vector<std::string> get_adapters() override;
std::set<Resolution> get_resolutions(unsigned adapter, unsigned format) override;
std::set<unsigned> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
std::set<uint32_t> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
bool has_anisotropy_support(unsigned adapter) override;

unsigned get_format_from_bpp(unsigned bpp) override
Expand Down Expand Up @@ -83,14 +83,23 @@ std::set<VideoDeviceInfoProvider::Resolution> VideoDeviceInfoProviderD3D8::get_r
return result;
}

std::set<unsigned> VideoDeviceInfoProviderD3D8::get_multisample_types(unsigned adapter, unsigned format, bool windowed)
std::set<uint32_t> VideoDeviceInfoProviderD3D8::get_multisample_types(
const unsigned adapter,
const unsigned format,
const bool windowed)
{
std::set<unsigned> result;
for (unsigned i = 2; i < 16; ++i) {
HRESULT hr = m_d3d->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, static_cast<D3DFORMAT>(format), windowed,
static_cast<D3DMULTISAMPLE_TYPE>(i));
if (SUCCEEDED(hr))
std::set<unsigned> result{};
for (uint32_t i = 2; i <= 16; ++i) {
const HRESULT hr = m_d3d->CheckDeviceMultiSampleType(
adapter,
D3DDEVTYPE_HAL,
static_cast<D3DFORMAT>(format),
windowed,
static_cast<D3DMULTISAMPLE_TYPE>(i)
);
if (SUCCEEDED(hr)) {
result.insert(i);
}
}
return result;
}
Expand Down
27 changes: 19 additions & 8 deletions launcher_common/VideoDeviceInfoProviderD3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VideoDeviceInfoProviderD3D9 : public VideoDeviceInfoProvider
~VideoDeviceInfoProviderD3D9() override = default;
std::vector<std::string> get_adapters() override;
std::set<Resolution> get_resolutions(unsigned adapter, unsigned format) override;
std::set<unsigned> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
std::set<uint32_t> get_multisample_types(unsigned adapter, unsigned format, bool windowed) override;
bool has_anisotropy_support(unsigned adapter) override;

unsigned get_format_from_bpp(unsigned bpp) override
Expand Down Expand Up @@ -83,14 +83,25 @@ std::set<VideoDeviceInfoProvider::Resolution> VideoDeviceInfoProviderD3D9::get_r
return result;
}

std::set<unsigned> VideoDeviceInfoProviderD3D9::get_multisample_types(unsigned adapter, unsigned format, bool windowed)
{
std::set<unsigned> result;
for (unsigned i = 2; i <= 16; ++i) {
HRESULT hr = m_d3d->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, static_cast<D3DFORMAT>(format), windowed,
static_cast<D3DMULTISAMPLE_TYPE>(i), nullptr);
if (SUCCEEDED(hr))
std::set<uint32_t> VideoDeviceInfoProviderD3D9::get_multisample_types(
const unsigned adapter,
const unsigned format,
const bool windowed
) {
std::set<uint32_t> result{};
for (uint32_t i = 2; i <= 16; ++i) {
DWORD quality_levels = 0;
const HRESULT hr = m_d3d->CheckDeviceMultiSampleType(
adapter,
D3DDEVTYPE_HAL,
static_cast<D3DFORMAT>(format),
windowed,
static_cast<D3DMULTISAMPLE_TYPE>(i),
&quality_levels
);
if (SUCCEEDED(hr) && quality_levels > 0) {
result.insert(i);
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VideoDeviceInfoProvider
virtual std::vector<std::string> get_adapters() = 0;
virtual unsigned get_format_from_bpp(unsigned bpp) = 0;
virtual std::set<Resolution> get_resolutions(unsigned adapter, unsigned format) = 0;
virtual std::set<unsigned> get_multisample_types(unsigned adapter, unsigned format, bool windowed) = 0;
virtual std::set<uint32_t> get_multisample_types(uint32_t adapter, uint32_t format, bool windowed) = 0;
virtual bool has_anisotropy_support(unsigned adapter) = 0;
};

Expand Down
Loading