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
7 changes: 6 additions & 1 deletion Bitmask.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#pragma once

#include <cassert>
#include <limits>
#include <type_traits>

namespace Ray {
template <class enum_type, typename = typename std::enable_if<std::is_enum<enum_type>::value>::type> class Bitmask {
using underlying_type = typename std::underlying_type<enum_type>::type;

static underlying_type to_mask(const enum_type e) { return 1 << static_cast<underlying_type>(e); }
static underlying_type to_mask(const enum_type e) {
assert(1ull << static_cast<underlying_type>(e) <= std::numeric_limits<underlying_type>::max());
return 1 << static_cast<underlying_type>(e);
}

explicit Bitmask(const underlying_type mask) : mask_(mask) {}

Expand Down
2 changes: 1 addition & 1 deletion internal/Dx/DrawCallDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace Ray {
namespace Dx {
extern const DXGI_FORMAT g_dx_formats[];
extern const DXGI_FORMAT g_formats_dx[];
}
} // namespace Ray

Expand Down
2 changes: 1 addition & 1 deletion internal/Dx/ResourceDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Ray::Dx::TransitionResourceStates(ID3D12GraphicsCommandList *cmd_buf, const
SmallVector<D3D12_RESOURCE_BARRIER, 64> barriers;

for (const TransitionInfo &transition : transitions) {
if (transition.p_tex && transition.p_tex->ready()) {
if (transition.p_tex && *transition.p_tex) {
eResState old_state = transition.old_state;
if (old_state == eResState::Undefined) {
// take state from resource itself
Expand Down
16 changes: 8 additions & 8 deletions internal/Dx/SamplerDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
namespace Ray {
namespace Dx {
#define X(_0, _1, _2, _3) _3,
extern const D3D12_FILTER g_dx_filter[] = {
extern const D3D12_FILTER g_filter_dx[] = {
#include "../TextureFilter.inl"
};
#undef X

#define X(_0, _1, _2) _2,
extern const D3D12_TEXTURE_ADDRESS_MODE g_dx_wrap_mode[] = {
extern const D3D12_TEXTURE_ADDRESS_MODE g_wrap_mode_dx[] = {
#include "../TextureWrap.inl"
};
#undef X

#define X(_0, _1, _2) _2,
extern const D3D12_COMPARISON_FUNC g_dx_compare_func[] = {
extern const D3D12_COMPARISON_FUNC g_compare_func_dx[] = {
#include "../TextureCompare.inl"
};
#undef X
Expand Down Expand Up @@ -62,16 +62,16 @@ void Ray::Dx::Sampler::Init(Context *ctx, const SamplingParams params) {
Free();

D3D12_SAMPLER_DESC sampler_desc = {};
sampler_desc.Filter = g_dx_filter[size_t(params.filter)];
sampler_desc.AddressU = g_dx_wrap_mode[size_t(params.wrap)];
sampler_desc.AddressV = g_dx_wrap_mode[size_t(params.wrap)];
sampler_desc.AddressW = g_dx_wrap_mode[size_t(params.wrap)];
sampler_desc.Filter = g_filter_dx[size_t(params.filter)];
sampler_desc.AddressU = g_wrap_mode_dx[size_t(params.wrap)];
sampler_desc.AddressV = g_wrap_mode_dx[size_t(params.wrap)];
sampler_desc.AddressW = g_wrap_mode_dx[size_t(params.wrap)];
sampler_desc.MipLODBias = params.lod_bias.to_float();
sampler_desc.MinLOD = params.min_lod.to_float();
sampler_desc.MaxLOD = params.max_lod.to_float();
sampler_desc.MaxAnisotropy = UINT(AnisotropyLevel);
if (params.compare != eTexCompare::None) {
sampler_desc.ComparisonFunc = g_dx_compare_func[size_t(params.compare)];
sampler_desc.ComparisonFunc = g_compare_func_dx[size_t(params.compare)];
}

ref_ = ctx->staging_descr_alloc()->Alloc(eDescrType::Sampler, 1);
Expand Down
10 changes: 5 additions & 5 deletions internal/Dx/TextureAtlasDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ template <> eTexFormat tex_format<uint8_t, 3>() { return eTexFormat::RGB8; }
template <> eTexFormat tex_format<uint8_t, 2>() { return eTexFormat::RG8; }
template <> eTexFormat tex_format<uint8_t, 1>() { return eTexFormat::R8; }

extern const DXGI_FORMAT g_dx_formats[];
extern const DXGI_FORMAT g_formats_dx[];

uint32_t D3D12CalcSubresource(uint32_t MipSlice, uint32_t ArraySlice, uint32_t PlaneSlice, uint32_t MipLevels,
uint32_t ArraySize);
Expand Down Expand Up @@ -240,7 +240,7 @@ bool Ray::Dx::TextureAtlas::Resize(const int pages_count) {
image_desc.Height = pages_count ? uint32_t(res_[1]) : 4;
image_desc.DepthOrArraySize = std::max(pages_count, 1);
image_desc.MipLevels = 1;
image_desc.Format = g_dx_formats[int(real_format_)];
image_desc.Format = g_formats_dx[int(real_format_)];
image_desc.SampleDesc.Count = 1;
image_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
image_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
Expand Down Expand Up @@ -289,7 +289,7 @@ bool Ray::Dx::TextureAtlas::Resize(const int pages_count) {
} else {
srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
}
srv_desc.Format = g_dx_formats[int(real_format_)];
srv_desc.Format = g_formats_dx[int(real_format_)];
srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
srv_desc.Texture2DArray.FirstArraySlice = 0;
srv_desc.Texture2DArray.ArraySize = std::max(pages_count, 1);
Expand Down Expand Up @@ -484,7 +484,7 @@ void Ray::Dx::TextureAtlas::WritePageData(const int page, const int posx, const
src_loc.PlacedFootprint.Footprint.Width = sizex;
src_loc.PlacedFootprint.Footprint.Height = sizey;
src_loc.PlacedFootprint.Footprint.Depth = 1;
src_loc.PlacedFootprint.Footprint.Format = g_dx_formats[int(real_format_)];
src_loc.PlacedFootprint.Footprint.Format = g_formats_dx[int(real_format_)];
src_loc.PlacedFootprint.Footprint.RowPitch = round_up(pitch, TextureDataPitchAlignment);

D3D12_TEXTURE_COPY_LOCATION dst_loc = {};
Expand Down Expand Up @@ -541,7 +541,7 @@ void Ray::Dx::TextureAtlas::CopyRegionTo(const int page, const int x, const int
dst_loc.PlacedFootprint.Footprint.Width = w;
dst_loc.PlacedFootprint.Footprint.Height = h;
dst_loc.PlacedFootprint.Footprint.Depth = 1;
dst_loc.PlacedFootprint.Footprint.Format = g_dx_formats[int(real_format_)];
dst_loc.PlacedFootprint.Footprint.Format = g_formats_dx[int(real_format_)];
if (IsCompressedFormat(real_format_)) {
dst_loc.PlacedFootprint.Footprint.RowPitch =
round_up(GetBlockCount(w, 1, real_format_) * GetBlockLenBytes(real_format_), TextureDataPitchAlignment);
Expand Down
Loading