[D3D12] ROV: Empty pixel shader for depth-only drawing
This commit is contained in:
parent
6e9964b43e
commit
2d56c9ae30
|
@ -15,6 +15,7 @@
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "xenia/base/assert.h"
|
#include "xenia/base/assert.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
|
@ -42,6 +43,11 @@ PipelineCache::PipelineCache(D3D12CommandProcessor* command_processor,
|
||||||
edram_rov_used_(edram_rov_used) {
|
edram_rov_used_(edram_rov_used) {
|
||||||
shader_translator_ = std::make_unique<DxbcShaderTranslator>(edram_rov_used_);
|
shader_translator_ = std::make_unique<DxbcShaderTranslator>(edram_rov_used_);
|
||||||
|
|
||||||
|
if (edram_rov_used_) {
|
||||||
|
depth_only_pixel_shader_ =
|
||||||
|
std::move(shader_translator_->CreateDepthOnlyPixelShader());
|
||||||
|
}
|
||||||
|
|
||||||
// Set pipeline state description values we never change.
|
// Set pipeline state description values we never change.
|
||||||
// Zero out tessellation, stream output, blend state and formats for render
|
// Zero out tessellation, stream output, blend state and formats for render
|
||||||
// targets 4+, node mask, cached PSO, flags and other things.
|
// targets 4+, node mask, cached PSO, flags and other things.
|
||||||
|
@ -325,8 +331,13 @@ PipelineCache::UpdateStatus PipelineCache::UpdateShaderStages(
|
||||||
update_desc_.PS.pShaderBytecode = pixel_shader->translated_binary().data();
|
update_desc_.PS.pShaderBytecode = pixel_shader->translated_binary().data();
|
||||||
update_desc_.PS.BytecodeLength = pixel_shader->translated_binary().size();
|
update_desc_.PS.BytecodeLength = pixel_shader->translated_binary().size();
|
||||||
} else {
|
} else {
|
||||||
update_desc_.PS.pShaderBytecode = nullptr;
|
if (edram_rov_used_) {
|
||||||
update_desc_.PS.BytecodeLength = 0;
|
update_desc_.PS.pShaderBytecode = depth_only_pixel_shader_.data();
|
||||||
|
update_desc_.PS.BytecodeLength = depth_only_pixel_shader_.size();
|
||||||
|
} else {
|
||||||
|
update_desc_.PS.pShaderBytecode = nullptr;
|
||||||
|
update_desc_.PS.BytecodeLength = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (primitive_type) {
|
switch (primitive_type) {
|
||||||
case PrimitiveType::kPointList:
|
case PrimitiveType::kPointList:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define XENIA_GPU_D3D12_PIPELINE_CACHE_H_
|
#define XENIA_GPU_D3D12_PIPELINE_CACHE_H_
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "third_party/xxhash/xxhash.h"
|
#include "third_party/xxhash/xxhash.h"
|
||||||
|
|
||||||
|
@ -93,6 +94,10 @@ class PipelineCache {
|
||||||
// All loaded shaders mapped by their guest hash key.
|
// All loaded shaders mapped by their guest hash key.
|
||||||
std::unordered_map<uint64_t, D3D12Shader*> shader_map_;
|
std::unordered_map<uint64_t, D3D12Shader*> shader_map_;
|
||||||
|
|
||||||
|
// Empty depth-only pixel shader for writing to depth buffer via ROV when no
|
||||||
|
// Xenos pixel shader provided.
|
||||||
|
std::vector<uint8_t> depth_only_pixel_shader_;
|
||||||
|
|
||||||
// Hash state used to incrementally produce pipeline hashes during update.
|
// Hash state used to incrementally produce pipeline hashes during update.
|
||||||
// By the time the full update pass has run the hash will represent the
|
// By the time the full update pass has run the hash will represent the
|
||||||
// current state in a way that can uniquely identify the produced
|
// current state in a way that can uniquely identify the produced
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -376,6 +376,10 @@ class DxbcShaderTranslator : public ShaderTranslator {
|
||||||
static bool GetBlendConstants(uint32_t blend_control, uint32_t& blend_x_out,
|
static bool GetBlendConstants(uint32_t blend_control, uint32_t& blend_x_out,
|
||||||
uint32_t& blend_y_out);
|
uint32_t& blend_y_out);
|
||||||
|
|
||||||
|
// Creates a special pixel shader without color outputs - this resets the
|
||||||
|
// state of the translator.
|
||||||
|
std::vector<uint8_t> CreateDepthOnlyPixelShader();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Reset() override;
|
void Reset() override;
|
||||||
|
|
||||||
|
@ -603,6 +607,15 @@ class DxbcShaderTranslator : public ShaderTranslator {
|
||||||
(index_representation_1 << 25) | (index_representation_2 << 28);
|
(index_representation_1 << 25) | (index_representation_2 << 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use these instead of is_vertex_shader/is_pixel_shader because they don't
|
||||||
|
// take is_depth_only_pixel_shader_ into account.
|
||||||
|
inline bool IsDXBCVertexShader() const {
|
||||||
|
return !is_depth_only_pixel_shader_ && is_vertex_shader();
|
||||||
|
}
|
||||||
|
inline bool IsDXBCPixelShader() const {
|
||||||
|
return is_depth_only_pixel_shader_ || is_pixel_shader();
|
||||||
|
}
|
||||||
|
|
||||||
// Allocates a new r# register for internal use and returns its index.
|
// Allocates a new r# register for internal use and returns its index.
|
||||||
uint32_t PushSystemTemp(bool zero = false);
|
uint32_t PushSystemTemp(bool zero = false);
|
||||||
// Frees the last allocated internal r# registers for later reuse.
|
// Frees the last allocated internal r# registers for later reuse.
|
||||||
|
@ -783,6 +796,10 @@ class DxbcShaderTranslator : public ShaderTranslator {
|
||||||
// Whether the output merger should be emulated in pixel shaders.
|
// Whether the output merger should be emulated in pixel shaders.
|
||||||
bool edram_rov_used_;
|
bool edram_rov_used_;
|
||||||
|
|
||||||
|
// Is currently writing the empty depth-only pixel shader, for
|
||||||
|
// CompleteTranslation.
|
||||||
|
bool is_depth_only_pixel_shader_;
|
||||||
|
|
||||||
// Data types used in constants buffers. Listed in dependency order.
|
// Data types used in constants buffers. Listed in dependency order.
|
||||||
enum class RdefTypeIndex {
|
enum class RdefTypeIndex {
|
||||||
kFloat,
|
kFloat,
|
||||||
|
|
Loading…
Reference in New Issue