core/d3d11: port filter dim cache from D3D12 backend
D3D11 parity port of the dim cache that landed for D3D12 in10c53b8. Same motivation: after418eb14the cbuffer-refactor series made resolution_scale / true_color / scaled_dithering toggles instant on D3D11, but a texture_filter flip still drove DestroyShaders + CompileShaders and recompiled the whole 144-cell batch pixel shader matrix (plus state objects, but those are a handful of cheap CreateBlendState / CreateRasterizerState calls). Add GPUTextureFilter::Count (7) as the outermost dimension of m_batch_pixel_shaders and m_batch_pixel_shader_fastpath: std::array<...<ComPtr<ID3D11PixelShader>, 2>, 2>, 9>, 4>, 7> ^ filter (D3D11 keeps its existing nested-std::array style rather than switching to DimensionalArray; matching the D3D12 backend's DimensionalArray<..., 7> at the indexing level is what matters, not the underlying container.) GetBatchPixelShader gains a GPUTextureFilter filter parameter as the first argument, indexes both arrays with [filter_idx][...], and constructs a per-call GPU_HW_ShaderGen against the requested filter rather than reusing m_shadergen (which stays bound to the runtime-current m_texture_filtering for the non-batch helpers called elsewhere - they don't depend on filter so rebuilding m_shadergen on every batch shader compile would be pure overhead). Filter is the only ctor input that differs between m_shadergen and the per-call shadergen; all other inputs come from member state that's single-valued per session. The expensive work (GenerateBatchFragmentShader call + D3DCompile + CreatePixelShader) is unchanged from the pre-dim-cache path. The error-log thread-safety check on m_shadergen is dropped because the per-call shadergen makes the helper independent of CompileShaders having constructed m_shadergen first; all call sites still go through CompileShaders or its descendants so the invariant is preserved structurally. CompileShaders's precompile_sync block snapshots cur_filter = m_texture_filtering once and walks only that sub-cube. Same pattern for ShaderCompileThreadEntryPoint - the worker captures cur_filter at launch and walks just that sub-cube. UpdateSettings calls StopShaderCompileThread BEFORE UpdateHWSettings writes m_texture_filtering, so the snapshot the worker takes always matches the filter it's supposed to be warming. The next CompileShaders pass after a filter flip launches a fresh worker captured to the new filter. Mirrors the D3D12 ordering verbatim. DrawBatchVertices passes m_texture_filtering as the first arg to GetBatchPixelShader so the lookup hits the active sub-cube. UpdateSettings's rebuild gate gains the only_dim_changed branch: if (shader_source_changed) { if (only_dim_changed) { // Filter sub-cube changed; others stay valid. // CompileShaders lazy-populates the new filter on top. // State objects are filter-independent so CreateStateObjects // can be skipped on this path - blend states key on // transparency_mode, depth-stencil on depth-test mode, // input layout on uv_limits (handled by non_dim_diff above). CompileShaders(); } else { // Non-dim shader change (MSAA / per-sample / UV limits / // chroma smoothing / PGXP depth / colour perspective / // precompile mode): every sub-cube is invalidated. DestroyShaders(); DestroyStateObjects(); CreateStateObjects(); CompileShaders(); } } Cycling back to a previously-visited filter (Nearest -> Bilinear -> Nearest) is now instant on D3D11 in any precompile mode - the second Nearest hit walks the precompile_sync loop and the fast-path atomic-load wins on every cell, no D3DCompile, no CreatePixelShader. A fresh-cold filter flip (first time visiting Bilinear) still pays the full matrix walk to populate the new sub-cube, but the OLD filter's shaders stay alive in their slots and are reachable via an atomic load the moment the user flips back. DestroyShaders's fast-path-clear loop gains a fifth level of nesting to match the new 5-D shape. Cost matrix after this patch (D3D11, default settings, shader_precompile_mode = Enabled, 144 reachable batch shader cells): Toggle Before After this patch texture_filter (cold) ~5-15 sec ~5-15 sec (necessary, new sub-cube) texture_filter (warm) ~5-15 sec instant (atomic load) resolution_scale zero unchanged true_color zero unchanged scaled_dithering zero unchanged multisamples ~5-15 sec unchanged (necessary - invalidates every filter sub-cube) per_sample_shading ~5-15 sec unchanged (necessary) uv_limits ~5-15 sec unchanged (necessary) pgxp_depth ~5-15 sec unchanged (necessary) disable_color_persp. ~5-15 sec unchanged (necessary) chroma_smoothing ~5-15 sec unchanged (suboptimal, same as D3D12 pre-57ac62e - splittable as a follow-up) shader_precompile_mode ~5-15 sec unchanged (intentional) D3D11 is fewer-tens-of-seconds than D3D12 in absolute terms because D3D11 has 144 batch shader cells vs D3D12's 1164 PSO cells (PSO state combinatorics inflate the count), but the relative improvement on warm filter cycling is the same. Test: - D3D11, shader_precompile = Enabled. First boot: matrix walks only Nearest's sub-cube. Shader compile count and progress bar match pre-patch. - Toggle texture filter Nearest -> Bilinear: precompile_sync walks Bilinear's sub-cube. Bilinear pixel shaders build for the first time. Old Nearest sub-cube stays populated. - Toggle back Bilinear -> Nearest: precompile_sync loop hits every Nearest slot on its fast-path atomic load and returns instantly. No D3DCompile, no progress OSD. - Toggle Nearest -> Bilinear again: every Bilinear slot is already populated. Instant. - Toggle resolution scale / true_color / scaled_dithering: still pays zero per418eb14, unchanged. - Toggle MSAA / per_sample / UV limits / PGXP depth / colour perspective: DestroyShaders clears all sub-cubes, full rebuild walks the current filter's sub-cube. Same cost as pre-patch. - shader_precompile_mode = Lazy: worker captures m_texture_filtering at launch, walks just that sub-cube. Filter toggle joins worker, restarts with new filter snapshot, walks new sub-cube. Main thread can fault any cell ahead of the worker via GetBatchPixelShader.
This commit is contained in:
parent
57ac62e792
commit
00cf11f5d0
2 changed files with 142 additions and 32 deletions
|
|
@ -579,6 +579,19 @@ void GPU_HW_D3D11::UpdateSettings()
|
|||
{
|
||||
GPU_HW::UpdateSettings();
|
||||
|
||||
// Stop the background batch-compile worker BEFORE UpdateHWSettings
|
||||
// writes m_texture_filtering. The worker captures m_texture_filtering
|
||||
// at launch and uses it for every GetBatchPixelShader call - if
|
||||
// the runloop thread flips it mid-iteration the worker would split
|
||||
// its filter-index read across old / new values, installing a
|
||||
// pixel shader compiled with one filter into a sub-cube indexed by
|
||||
// another. Joining first eliminates the race; the next
|
||||
// CompileShaders below restarts a worker for the new filter as
|
||||
// appropriate. StopShaderCompileThread is idempotent, so the
|
||||
// matching call inside DestroyShaders just becomes a no-op on
|
||||
// this path. Mirrors the D3D12 ordering in 10c53b8.
|
||||
StopShaderCompileThread();
|
||||
|
||||
// See GPU_HW_D3D12::UpdateSettings for the rationale on
|
||||
// shader_source_changed vs shaders_changed: the cbuffer-refactor
|
||||
// patch made true_color / scaled_dithering / resolution_scale
|
||||
|
|
@ -589,8 +602,15 @@ void GPU_HW_D3D11::UpdateSettings()
|
|||
// objects also stay valid through those toggles because their
|
||||
// descriptions key on MSAA / dual-source / depth-test / blend
|
||||
// mode - none of which are in the cbuffer-only set.
|
||||
bool framebuffer_changed, shaders_changed, shader_source_changed;
|
||||
UpdateHWSettings(&framebuffer_changed, &shaders_changed, nullptr, nullptr, &shader_source_changed);
|
||||
//
|
||||
// only_dim_changed: dim-cube setting (filter / true_color /
|
||||
// scaled_dithering) changed and nothing in non_dim_diff. With the
|
||||
// dim cache (filter outermost) this means "filter sub-cube can
|
||||
// be lazy-populated, other filters' sub-cubes stay valid". When
|
||||
// set alongside shader_source_changed it picks out the
|
||||
// filter-only-changed case.
|
||||
bool framebuffer_changed, shaders_changed, only_dim_changed, shader_source_changed;
|
||||
UpdateHWSettings(&framebuffer_changed, &shaders_changed, &only_dim_changed, nullptr, &shader_source_changed);
|
||||
|
||||
if (framebuffer_changed)
|
||||
{
|
||||
|
|
@ -603,10 +623,40 @@ void GPU_HW_D3D11::UpdateSettings()
|
|||
|
||||
if (shader_source_changed)
|
||||
{
|
||||
DestroyShaders();
|
||||
DestroyStateObjects();
|
||||
CreateStateObjects();
|
||||
CompileShaders();
|
||||
if (only_dim_changed)
|
||||
{
|
||||
// Filter changed but nothing in non_dim_diff (and the cbuffer-
|
||||
// only members in dim_diff don't move HLSL, so this is
|
||||
// effectively "only filter changed"). m_batch_pixel_shaders is
|
||||
// filter-dimensioned: the previous filter's sub-cube remains
|
||||
// populated and reachable, so DestroyShaders would just throw
|
||||
// away valid pixel shaders. Skip it and just call
|
||||
// CompileShaders, which lazy-populates the new filter's
|
||||
// sub-cube on top: in Enabled mode the precompile_sync loop
|
||||
// walks the matrix calling GetBatchPixelShader with the new
|
||||
// m_texture_filtering, so the other sub-cubes are untouched.
|
||||
// In Lazy / Disabled the new sub-cube stays empty until first
|
||||
// draw / the worker reaches each cell.
|
||||
//
|
||||
// Cycling back to a previously-visited filter is instant -
|
||||
// no D3DCompile, no CreatePixelShader, just an atomic load of
|
||||
// an already-filled slot. State objects (blend / depth /
|
||||
// input layout) are filter-independent and also stay valid;
|
||||
// CreateStateObjects is skipped on this branch.
|
||||
CompileShaders();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full flush: a non-dim shader-affecting change
|
||||
// (multisamples / per-sample shading / UV limits / chroma
|
||||
// smoothing / PGXP depth / colour perspective / precompile
|
||||
// mode) invalidates EVERY sub-cube because those settings
|
||||
// bake into the HLSL identically for every filter slot.
|
||||
DestroyShaders();
|
||||
DestroyStateObjects();
|
||||
CreateStateObjects();
|
||||
CompileShaders();
|
||||
}
|
||||
}
|
||||
|
||||
if (framebuffer_changed)
|
||||
|
|
@ -1045,6 +1095,15 @@ bool GPU_HW_D3D11::CompileShaders()
|
|||
if (precompile_sync)
|
||||
{
|
||||
const bool dual_source = m_supports_dual_source_blend;
|
||||
// The dim cache makes m_batch_pixel_shaders filter-dimensioned.
|
||||
// precompile_sync walks ONLY the current m_texture_filtering
|
||||
// sub-cube, not the full 7-filter matrix - pre-filling six
|
||||
// unused sub-cubes would multiply the cold-cache D3DCompile
|
||||
// pass by 7x for no gain (the game can only be running under
|
||||
// one filter at a time, and the other sub-cubes get faulted in
|
||||
// on demand if the user later flips the filter setting and
|
||||
// UpdateSettings calls CompileShaders again).
|
||||
const GPUTextureFilter cur_filter = m_texture_filtering;
|
||||
for (uint8_t render_mode = 0; render_mode < 4; render_mode++)
|
||||
{
|
||||
for (uint8_t texture_mode = 0; texture_mode < 9; texture_mode++)
|
||||
|
|
@ -1056,7 +1115,7 @@ bool GPU_HW_D3D11::CompileShaders()
|
|||
{
|
||||
for (uint8_t interlacing = 0; interlacing < 2; interlacing++)
|
||||
{
|
||||
ID3D11PixelShader* shader = GetBatchPixelShader(render_mode, texture_mode,
|
||||
ID3D11PixelShader* shader = GetBatchPixelShader(cur_filter, render_mode, texture_mode,
|
||||
static_cast<bool>(dithering),
|
||||
static_cast<bool>(interlacing));
|
||||
if (!shader)
|
||||
|
|
@ -1218,7 +1277,20 @@ void GPU_HW_D3D11::ShaderCompileThreadEntryPoint()
|
|||
// two-pass-fallback render modes with no texture are never
|
||||
// selected by FlushRender. TransparentAndOpaque with a texture
|
||||
// mode is never selected on hardware without dual-source blend.
|
||||
//
|
||||
// The worker captures the runtime-current m_texture_filtering at
|
||||
// launch time and walks only that filter's sub-cube. Mirrors what
|
||||
// CompileShaders does in precompile_sync mode - both paths fill
|
||||
// the active filter's sub-cube and leave the other six sub-cubes
|
||||
// empty, to be lazy-faulted in via GetBatchPixelShader on the
|
||||
// main thread if a filter toggle later brings them into use.
|
||||
// UpdateSettings calls StopShaderCompileThread BEFORE
|
||||
// UpdateHWSettings writes m_texture_filtering, so the snapshot
|
||||
// here matches the filter the worker is supposed to be warming -
|
||||
// the next CompileShaders starts a fresh worker for the new
|
||||
// filter.
|
||||
const bool dual_source = m_supports_dual_source_blend;
|
||||
const GPUTextureFilter cur_filter = m_texture_filtering;
|
||||
for (uint8_t render_mode = 0; render_mode < 4; render_mode++)
|
||||
{
|
||||
for (uint8_t texture_mode = 0; texture_mode < 9; texture_mode++)
|
||||
|
|
@ -1233,7 +1305,7 @@ void GPU_HW_D3D11::ShaderCompileThreadEntryPoint()
|
|||
if (m_shader_compile_thread_quit.load(std::memory_order_relaxed))
|
||||
return;
|
||||
|
||||
GetBatchPixelShader(render_mode, texture_mode, static_cast<bool>(dithering),
|
||||
GetBatchPixelShader(cur_filter, render_mode, texture_mode, static_cast<bool>(dithering),
|
||||
static_cast<bool>(interlacing));
|
||||
}
|
||||
}
|
||||
|
|
@ -1241,7 +1313,7 @@ void GPU_HW_D3D11::ShaderCompileThreadEntryPoint()
|
|||
}
|
||||
}
|
||||
|
||||
ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(uint8_t render_mode, uint8_t texture_mode, bool dithering, bool interlacing)
|
||||
ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(GPUTextureFilter filter, uint8_t render_mode, uint8_t texture_mode, bool dithering, bool interlacing)
|
||||
{
|
||||
// Apply the Reserved_*Direct16Bit dedup at the matrix level. The
|
||||
// shader source for texture_mode 3 / 7 is byte-for-byte identical
|
||||
|
|
@ -1252,13 +1324,14 @@ ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(uint8_t render_mode, uint8_
|
|||
const uint8_t lookup_mode = (texture_mode == static_cast<uint8_t>(GPUTextureMode::Reserved_Direct16Bit)) ? 2u :
|
||||
(texture_mode == static_cast<uint8_t>(GPUTextureMode::Reserved_RawDirect16Bit)) ? 6u :
|
||||
texture_mode;
|
||||
const uint8_t filter_idx = static_cast<uint8_t>(filter);
|
||||
|
||||
// Fast path: lock-free atomic acquire-load of the caller's slot.
|
||||
// If it's filled (the worker reached it first, or an earlier
|
||||
// main-thread fault-in did), we're done with no mutex / kernel
|
||||
// call / contention against the worker.
|
||||
std::atomic<ID3D11PixelShader*>& fast_slot =
|
||||
m_batch_pixel_shader_fastpath[render_mode][texture_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
m_batch_pixel_shader_fastpath[filter_idx][render_mode][texture_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
ID3D11PixelShader* existing = fast_slot.load(std::memory_order_acquire);
|
||||
if (existing)
|
||||
return existing;
|
||||
|
|
@ -1274,18 +1347,28 @@ ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(uint8_t render_mode, uint8_
|
|||
// SAME slot both produce equivalent ID3D11PixelShader objects;
|
||||
// the loser's ComPtr is released when it falls out of scope
|
||||
// below.
|
||||
if (!m_shadergen)
|
||||
{
|
||||
Log_ErrorPrint("GetBatchPixelShader called before CompileShaders constructed the shadergen");
|
||||
return nullptr;
|
||||
}
|
||||
const std::string ps = m_shadergen->GenerateBatchFragmentShader(
|
||||
//
|
||||
// Construct a per-call shadergen bound to the requested filter
|
||||
// rather than reusing m_shadergen (which is pinned to the
|
||||
// runtime-current m_texture_filtering for the non-batch helpers).
|
||||
// Filter is the only setting that differs between this shadergen
|
||||
// and m_shadergen - all other inputs come from member state that
|
||||
// is single-valued per session. Construction is a handful of POD
|
||||
// copies; the expensive work is GenerateBatchFragmentShader +
|
||||
// D3DCompile + CreatePixelShader that follow, all unchanged from
|
||||
// the pre-dim-cache path.
|
||||
GPU_HW_ShaderGen tmp_shadergen(
|
||||
m_host_display->GetRenderAPI(), m_resolution_scale, m_multisamples, m_per_sample_shading, m_true_color,
|
||||
m_scaled_dithering, filter, m_using_uv_limits, m_pgxp_depth_buffer, m_disable_color_perspective,
|
||||
m_supports_dual_source_blend);
|
||||
const std::string ps = tmp_shadergen.GenerateBatchFragmentShader(
|
||||
static_cast<BatchRenderMode>(render_mode), static_cast<GPUTextureMode>(lookup_mode), dithering, interlacing);
|
||||
ComPtr<ID3D11PixelShader> fresh = m_shader_cache.GetPixelShader(m_device.Get(), ps);
|
||||
if (!fresh)
|
||||
{
|
||||
Log_ErrorPrintf("Lazy batch pixel shader compile failed for (rm=%u, tm=%u, d=%u, i=%u)", render_mode,
|
||||
texture_mode, static_cast<uint8_t>(dithering), static_cast<uint8_t>(interlacing));
|
||||
Log_ErrorPrintf("Lazy batch pixel shader compile failed for (f=%u, rm=%u, tm=%u, d=%u, i=%u)",
|
||||
static_cast<uint8_t>(filter), render_mode, texture_mode,
|
||||
static_cast<uint8_t>(dithering), static_cast<uint8_t>(interlacing));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -1300,14 +1383,14 @@ ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(uint8_t render_mode, uint8_
|
|||
return existing;
|
||||
|
||||
ComPtr<ID3D11PixelShader>& canonical_slot =
|
||||
m_batch_pixel_shaders[render_mode][lookup_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
m_batch_pixel_shaders[filter_idx][render_mode][lookup_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
|
||||
if (!canonical_slot)
|
||||
{
|
||||
// We won the race on the canonical slot - take ownership of
|
||||
// our freshly-compiled shader.
|
||||
canonical_slot = fresh;
|
||||
m_batch_pixel_shader_fastpath[render_mode][lookup_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)].store(
|
||||
m_batch_pixel_shader_fastpath[filter_idx][render_mode][lookup_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)].store(
|
||||
canonical_slot.Get(), std::memory_order_release);
|
||||
}
|
||||
// Else: canonical_slot was already filled by another racing
|
||||
|
|
@ -1318,7 +1401,7 @@ ID3D11PixelShader* GPU_HW_D3D11::GetBatchPixelShader(uint8_t render_mode, uint8_
|
|||
if (lookup_mode != texture_mode)
|
||||
{
|
||||
ComPtr<ID3D11PixelShader>& dup_slot =
|
||||
m_batch_pixel_shaders[render_mode][texture_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
m_batch_pixel_shaders[filter_idx][render_mode][texture_mode][static_cast<uint8_t>(dithering)][static_cast<uint8_t>(interlacing)];
|
||||
if (!dup_slot)
|
||||
dup_slot = canonical_slot;
|
||||
}
|
||||
|
|
@ -1359,11 +1442,15 @@ void GPU_HW_D3D11::DestroyShaders()
|
|||
// runloop isn't drawing (UpdateSettings is the only call site that
|
||||
// goes through DestroyShaders, and it's on the runloop thread
|
||||
// itself), so memory_order_relaxed is sufficient.
|
||||
//
|
||||
// 5-level nesting matches the [filter][render][texture][dither][interlace]
|
||||
// shape of m_batch_pixel_shader_fastpath added in the dim cache port.
|
||||
for (auto& a : m_batch_pixel_shader_fastpath)
|
||||
for (auto& b : a)
|
||||
for (auto& c : b)
|
||||
for (auto& slot : c)
|
||||
slot.store(nullptr, std::memory_order_relaxed);
|
||||
for (auto& d : c)
|
||||
for (auto& slot : d)
|
||||
slot.store(nullptr, std::memory_order_relaxed);
|
||||
|
||||
m_batch_pixel_shaders = {};
|
||||
m_batch_vertex_shaders = {};
|
||||
|
|
@ -1485,8 +1572,14 @@ void GPU_HW_D3D11::DrawBatchVertices(BatchRenderMode render_mode, uint32_t base_
|
|||
// (game raced ahead of the worker). In 'Disabled' mode it always
|
||||
// compiles on miss. The mutex guards both the cache and the
|
||||
// matrix; cost is ~20 ns uncontended per modern std::mutex impl.
|
||||
//
|
||||
// m_texture_filtering selects the active filter's sub-cube. Filter
|
||||
// is the outermost dim so a filter toggle in UpdateSettings can
|
||||
// skip DestroyShaders - the other filters' sub-cubes remain valid
|
||||
// and reachable, switching back to a previously-visited filter is
|
||||
// an atomic load on an already-filled slot.
|
||||
ID3D11PixelShader* batch_pixel_shader =
|
||||
GetBatchPixelShader(static_cast<uint8_t>(render_mode), static_cast<uint8_t>(m_batch.texture_mode), m_batch.dithering,
|
||||
GetBatchPixelShader(m_texture_filtering, static_cast<uint8_t>(render_mode), static_cast<uint8_t>(m_batch.texture_mode), m_batch.dithering,
|
||||
m_batch.interlacing);
|
||||
m_context->PSSetShader(batch_pixel_shader, nullptr, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,23 @@ private:
|
|||
// ID3D11PixelShader* itself is free-threaded for the consumer
|
||||
// side (PSSetShader), so DrawBatchVertices can use the raw
|
||||
// pointer returned here without further locking.
|
||||
ID3D11PixelShader* GetBatchPixelShader(uint8_t render_mode, uint8_t texture_mode, bool dithering, bool interlacing);
|
||||
//
|
||||
// filter is the outermost cache dimension. With the cbuffer-
|
||||
// refactor patch (7b575a3) the HLSL is invariant under
|
||||
// resolution_scale / true_color / scaled_dithering, but it is
|
||||
// STILL dependent on texture filter - the FilteredSampleFromVRAM
|
||||
// helper is emitted differently for Nearest / Bilinear / JINC2 /
|
||||
// xBR / the BinAlpha variants. Dimensioning the cache over filter
|
||||
// lets a filter toggle skip the DestroyShaders round trip in
|
||||
// UpdateSettings: the previous filter's sub-cube remains valid
|
||||
// and reachable, switching back to it later is an atomic load on
|
||||
// an already-filled slot. Mirrors the D3D12 dim cache landed in
|
||||
// 10c53b8 and the Vulkan dim cache from the glslang-elimination
|
||||
// series. The slow-path shadergen is rebuilt per-call against
|
||||
// the requested filter so a worker / main-thread fault for a
|
||||
// non-current filter's sub-cube generates HLSL for that filter,
|
||||
// not for m_texture_filtering.
|
||||
ID3D11PixelShader* GetBatchPixelShader(GPUTextureFilter filter, uint8_t render_mode, uint8_t texture_mode, bool dithering, bool interlacing);
|
||||
|
||||
// Background-thread worker for 'Lazy' mode: walks the entire
|
||||
// (render_mode, texture_mode, dithering, interlacing) matrix and
|
||||
|
|
@ -227,9 +243,10 @@ private:
|
|||
ComPtr<ID3D11InputLayout> m_batch_input_layout;
|
||||
std::array<ComPtr<ID3D11VertexShader>, 2> m_batch_vertex_shaders; // [textured]
|
||||
|
||||
// Batch pixel shader matrix. The ComPtr array owns the
|
||||
// reference; the parallel atomic-raw-pointer array exists so
|
||||
// DrawBatchVertices can sample a slot without taking any lock.
|
||||
// Batch pixel shader matrix. Filter is the outermost dimension -
|
||||
// see the comment on GetBatchPixelShader above for why.
|
||||
//
|
||||
// [filter][render_mode][texture_mode][dithering][interlacing]
|
||||
//
|
||||
// m_batch_pixel_shaders holds the COM ownership and is only
|
||||
// written under m_batch_shader_mutex (in GetBatchPixelShader's
|
||||
|
|
@ -255,10 +272,10 @@ private:
|
|||
// first run. With this design DrawBatchVertices is lock-free on
|
||||
// cache-hit AND on race the slow path doesn't block the worker
|
||||
// either; the worker can compile in the background unmolested.
|
||||
std::array<std::array<std::array<std::array<ComPtr<ID3D11PixelShader>, 2>, 2>, 9>, 4>
|
||||
m_batch_pixel_shaders; // [render_mode][texture_mode][dithering][interlacing]
|
||||
std::array<std::array<std::array<std::array<std::atomic<ID3D11PixelShader*>, 2>, 2>, 9>, 4>
|
||||
m_batch_pixel_shader_fastpath{}; // [render_mode][texture_mode][dithering][interlacing]
|
||||
std::array<std::array<std::array<std::array<std::array<ComPtr<ID3D11PixelShader>, 2>, 2>, 9>, 4>, 7>
|
||||
m_batch_pixel_shaders; // [filter][render_mode][texture_mode][dithering][interlacing]
|
||||
std::array<std::array<std::array<std::array<std::array<std::atomic<ID3D11PixelShader*>, 2>, 2>, 9>, 4>, 7>
|
||||
m_batch_pixel_shader_fastpath{}; // [filter][render_mode][texture_mode][dithering][interlacing]
|
||||
|
||||
// Persistent shader cache and shadergen instances for the lazy
|
||||
// / background-thread compile path. Both used to be locals in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue