DX12: renames.

This commit is contained in:
Artem Kharytoniuk 2017-12-25 09:44:54 +01:00
parent aa43a0e5a5
commit ac233e7ab9
9 changed files with 90 additions and 84 deletions

View File

@ -424,7 +424,7 @@ void dx_initialize() {
def.polygon_offset = false;
def.clipping_plane = false;
def.mirror = false;
dx.skybox_pipeline_state = create_pipeline(def);
dx.skybox_pipeline = create_pipeline(def);
}
// Q3 stencil shadows
@ -444,7 +444,7 @@ void dx_initialize() {
def.face_culling = cull_types[i];
for (int j = 0; j < 2; j++) {
def.mirror = mirror_flags[j];
dx.shadow_volume_pipeline_states[i][j] = create_pipeline(def);
dx.shadow_volume_pipelines[i][j] = create_pipeline(def);
}
}
}
@ -458,7 +458,7 @@ void dx_initialize() {
def.clipping_plane = false;
def.mirror = false;
def.shadow_phase = Vk_Shadow_Phase::fullscreen_quad_rendering;
dx.shadow_finish_pipeline_state = create_pipeline(def);
dx.shadow_finish_pipeline = create_pipeline(def);
}
}
@ -490,10 +490,10 @@ void dx_initialize() {
def.polygon_offset = polygon_offset[k];
def.state_bits = fog_state;
dx.fog_pipeline_states[i][j][k] = create_pipeline(def);
dx.fog_pipelines[i][j][k] = create_pipeline(def);
def.state_bits = dlight_state;
dx.dlight_pipeline_states[i][j][k] = create_pipeline(def);
dx.dlight_pipelines[i][j][k] = create_pipeline(def);
}
}
}
@ -503,35 +503,35 @@ void dx_initialize() {
{
Vk_Pipeline_Def def;
def.state_bits = GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE;
dx.tris_debug_pipeline_state = create_pipeline(def);
dx.tris_debug_pipeline = create_pipeline(def);
}
{
Vk_Pipeline_Def def;
def.state_bits = GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE;
def.face_culling = CT_BACK_SIDED;
dx.tris_mirror_debug_pipeline_state = create_pipeline(def);
dx.tris_mirror_debug_pipeline = create_pipeline(def);
}
{
Vk_Pipeline_Def def;
def.state_bits = GLS_DEPTHMASK_TRUE;
def.line_primitives = true;
dx.normals_debug_pipeline_state = create_pipeline(def);
dx.normals_debug_pipeline = create_pipeline(def);
}
{
Vk_Pipeline_Def def;
def.state_bits = GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE;
dx.surface_debug_pipeline_state_solid = create_pipeline(def);
dx.surface_debug_pipeline_solid = create_pipeline(def);
}
{
Vk_Pipeline_Def def;
def.state_bits = GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE;
def.line_primitives = true;
dx.surface_debug_pipeline_state_outline = create_pipeline(def);
dx.surface_debug_pipeline_outline = create_pipeline(def);
}
{
Vk_Pipeline_Def def;
def.state_bits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
dx.images_debug_pipeline_state = create_pipeline(def);
dx.images_debug_pipeline = create_pipeline(def);
}
}
@ -546,14 +546,14 @@ void dx_shutdown() {
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
dx.shadow_volume_pipeline_states[i][j]->Release();
dx.shadow_volume_pipelines[i][j]->Release();
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
for (int k = 0; k < 2; k++) {
dx.fog_pipeline_states[i][j][k]->Release();
dx.dlight_pipeline_states[i][j][k]->Release();
dx.fog_pipelines[i][j][k]->Release();
dx.dlight_pipelines[i][j][k]->Release();
}
}
}
@ -571,14 +571,14 @@ void dx_shutdown() {
dx.depth_stencil_buffer->Release();
dx.dsv_heap->Release();
dx.geometry_buffer->Release();
dx.skybox_pipeline_state->Release();
dx.shadow_finish_pipeline_state->Release();
dx.tris_debug_pipeline_state->Release();
dx.tris_mirror_debug_pipeline_state->Release();
dx.normals_debug_pipeline_state->Release();
dx.surface_debug_pipeline_state_solid->Release();
dx.surface_debug_pipeline_state_outline->Release();
dx.images_debug_pipeline_state->Release();
dx.skybox_pipeline->Release();
dx.shadow_finish_pipeline->Release();
dx.tris_debug_pipeline->Release();
dx.tris_mirror_debug_pipeline->Release();
dx.normals_debug_pipeline->Release();
dx.surface_debug_pipeline_solid->Release();
dx.surface_debug_pipeline_outline->Release();
dx.images_debug_pipeline->Release();
dx.device->Release();
@ -589,8 +589,8 @@ void dx_release_resources() {
dx_wait_device_idle();
dx_world.pipeline_create_time = 0.0f;
for (int i = 0; i < dx_world.num_pipeline_states; i++) {
dx_world.pipeline_states[i]->Release();
for (int i = 0; i < dx_world.num_pipelines; i++) {
dx_world.pipelines[i]->Release();
}
for (int i = 0; i < MAX_VK_IMAGES; i++) {
@ -1034,9 +1034,9 @@ static ID3D12PipelineState* create_pipeline(const Vk_Pipeline_Def& def) {
pipeline_desc.SampleDesc.Count = 1;
pipeline_desc.SampleDesc.Quality = 0;
ID3D12PipelineState* pipeline_state;
DX_CHECK(dx.device->CreateGraphicsPipelineState(&pipeline_desc, IID_PPV_ARGS(&pipeline_state)));
return pipeline_state;
ID3D12PipelineState* pipeline;
DX_CHECK(dx.device->CreateGraphicsPipelineState(&pipeline_desc, IID_PPV_ARGS(&pipeline)));
return pipeline;
}
struct Timer {
@ -1112,7 +1112,7 @@ void dx_create_sampler_descriptor(const Vk_Sampler_Def& def, Dx_Sampler_Index sa
}
ID3D12PipelineState* dx_find_pipeline(const Vk_Pipeline_Def& def) {
for (int i = 0; i < dx_world.num_pipeline_states; i++) {
for (int i = 0; i < dx_world.num_pipelines; i++) {
const auto& cur_def = dx_world.pipeline_defs[i];
if (cur_def.shader_type == def.shader_type &&
@ -1124,22 +1124,22 @@ ID3D12PipelineState* dx_find_pipeline(const Vk_Pipeline_Def& def) {
cur_def.line_primitives == def.line_primitives &&
cur_def.shadow_phase == def.shadow_phase)
{
return dx_world.pipeline_states[i];
return dx_world.pipelines[i];
}
}
if (dx_world.num_pipeline_states >= MAX_VK_PIPELINES) {
if (dx_world.num_pipelines >= MAX_VK_PIPELINES) {
ri.Error(ERR_DROP, "dx_find_pipeline: MAX_VK_PIPELINES hit\n");
}
Timer t;
ID3D12PipelineState* pipeline_state = create_pipeline(def);
ID3D12PipelineState* pipeline = create_pipeline(def);
dx_world.pipeline_create_time += t.elapsed_seconds();
dx_world.pipeline_defs[dx_world.num_pipeline_states] = def;
dx_world.pipeline_states[dx_world.num_pipeline_states] = pipeline_state;
dx_world.num_pipeline_states++;
return pipeline_state;
dx_world.pipeline_defs[dx_world.num_pipelines] = def;
dx_world.pipelines[dx_world.num_pipelines] = pipeline;
dx_world.num_pipelines++;
return pipeline;
}
static void get_mvp_transform(float* mvp) {
@ -1337,7 +1337,7 @@ void dx_bind_geometry() {
dx.command_list->SetGraphicsRoot32BitConstants(0, root_constant_count, root_constants, 0);
}
void dx_shade_geometry(ID3D12PipelineState* pipeline_state, bool multitexture, Vk_Depth_Range depth_range, bool indexed, bool lines) {
void dx_shade_geometry(ID3D12PipelineState* pipeline, bool multitexture, Vk_Depth_Range depth_range, bool indexed, bool lines) {
// color
{
if ((dx.color_st_elements + tess.numVertexes) * sizeof(color4ub_t) > COLOR_SIZE)
@ -1410,7 +1410,7 @@ void dx_shade_geometry(ID3D12PipelineState* pipeline_state, bool multitexture, V
//
// Configure pipeline.
//
dx.command_list->SetPipelineState(pipeline_state);
dx.command_list->SetPipelineState(pipeline);
dx.command_list->IASetPrimitiveTopology(lines ? D3D10_PRIMITIVE_TOPOLOGY_LINELIST : D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
D3D12_RECT scissor_rect = get_scissor_rect();

View File

@ -53,7 +53,7 @@ ID3D12PipelineState* dx_find_pipeline(const Vk_Pipeline_Def& def);
//
void dx_clear_attachments(bool clear_depth_stencil, bool clear_color, vec4_t color);
void dx_bind_geometry();
void dx_shade_geometry(ID3D12PipelineState* pipeline_state, bool multitexture, Vk_Depth_Range depth_range, bool indexed, bool lines);
void dx_shade_geometry(ID3D12PipelineState* pipeline, bool multitexture, Vk_Depth_Range depth_range, bool indexed, bool lines);
void dx_begin_frame();
void dx_end_frame();
@ -107,39 +107,39 @@ struct Dx_Instance {
//
// Standard pipelines.
//
ID3D12PipelineState* skybox_pipeline_state = nullptr;
ID3D12PipelineState* skybox_pipeline = nullptr;
// dim 0: 0 - front side, 1 - back size
// dim 1: 0 - normal view, 1 - mirror view
ID3D12PipelineState* shadow_volume_pipeline_states[2][2];
ID3D12PipelineState* shadow_finish_pipeline_state = nullptr;
ID3D12PipelineState* shadow_volume_pipelines[2][2];
ID3D12PipelineState* shadow_finish_pipeline = nullptr;
// dim 0 is based on fogPass_t: 0 - corresponds to FP_EQUAL, 1 - corresponds to FP_LE.
// dim 1 is directly a cullType_t enum value.
// dim 2 is a polygon offset value (0 - off, 1 - on).
ID3D12PipelineState* fog_pipeline_states[2][3][2];
ID3D12PipelineState* fog_pipelines[2][3][2];
// dim 0 is based on dlight additive flag: 0 - not additive, 1 - additive
// dim 1 is directly a cullType_t enum value.
// dim 2 is a polygon offset value (0 - off, 1 - on).
ID3D12PipelineState* dlight_pipeline_states[2][3][2];
ID3D12PipelineState* dlight_pipelines[2][3][2];
// debug visualization pipelines
ID3D12PipelineState* tris_debug_pipeline_state = nullptr;
ID3D12PipelineState* tris_mirror_debug_pipeline_state = nullptr;
ID3D12PipelineState* normals_debug_pipeline_state = nullptr;
ID3D12PipelineState* surface_debug_pipeline_state_solid = nullptr;
ID3D12PipelineState* surface_debug_pipeline_state_outline = nullptr;
ID3D12PipelineState* images_debug_pipeline_state = nullptr;
ID3D12PipelineState* tris_debug_pipeline = nullptr;
ID3D12PipelineState* tris_mirror_debug_pipeline = nullptr;
ID3D12PipelineState* normals_debug_pipeline = nullptr;
ID3D12PipelineState* surface_debug_pipeline_solid = nullptr;
ID3D12PipelineState* surface_debug_pipeline_outline = nullptr;
ID3D12PipelineState* images_debug_pipeline = nullptr;
};
struct Dx_World {
//
// Resources.
//
int num_pipeline_states = 0;
int num_pipelines = 0;
Vk_Pipeline_Def pipeline_defs[MAX_VK_PIPELINES];
ID3D12PipelineState* pipeline_states[MAX_VK_PIPELINES];
ID3D12PipelineState* pipelines[MAX_VK_PIPELINES];
float pipeline_create_time;
Dx_Image images[MAX_VK_IMAGES];

View File

@ -908,16 +908,22 @@ const void *RB_DrawBuffer( const void *data ) {
// clear screen for debugging
if ( r_clear->integer ) {
qglClearColor( 1, 0, 0.5, 1 );
float color[4] = {1, 0, 0.5, 1};
qglClearColor( color[0], color[1], color[2], color[3] );
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// VULKAN
RB_SetGL2D(); // to ensure we have viewport that occupies entire window
float color[4] = {1, 0, 0.5, 1};
vk_clear_attachments(false, true, color);
if (vk.active) {
RB_SetGL2D(); // to ensure we have viewport that occupies entire window
vk_clear_attachments(false, true, color);
}
// DX12
dx_clear_attachments(false, true, color);
if (dx.active) {
RB_SetGL2D(); // to ensure we have viewport that occupies entire window
dx_clear_attachments(false, true, color);
}
}
return (const void *)(cmd + 1);
@ -1060,7 +1066,7 @@ void RB_Show_Vk_Dx_Images() {
}
if (dx.active) {
dx_bind_geometry();
dx_shade_geometry(dx.images_debug_pipeline_state, false, Vk_Depth_Range::normal, true, false);
dx_shade_geometry(dx.images_debug_pipeline, false, Vk_Depth_Range::normal, true, false);
}
}
tess.numIndexes = 0;

View File

@ -327,9 +327,9 @@ typedef struct {
VkPipeline vk_mirror_pipeline = VK_NULL_HANDLE;
// DX12
ID3D12PipelineState* dx_pipeline_state = nullptr;
ID3D12PipelineState* dx_portal_pipeline_state = nullptr;
ID3D12PipelineState* dx_mirror_pipeline_state = nullptr;
ID3D12PipelineState* dx_pipeline = nullptr;
ID3D12PipelineState* dx_portal_pipeline = nullptr;
ID3D12PipelineState* dx_mirror_pipeline = nullptr;
} shaderStage_t;

View File

@ -1465,7 +1465,7 @@ void R_DebugPolygon( int color, int numPoints, float *points ) {
vk_shade_geometry(vk.surface_debug_pipeline_solid, false, Vk_Depth_Range::normal);
dx_bind_geometry();
dx_shade_geometry(dx.surface_debug_pipeline_state_solid, false, Vk_Depth_Range::normal, true, false);
dx_shade_geometry(dx.surface_debug_pipeline_solid, false, Vk_Depth_Range::normal, true, false);
// Outline.
Com_Memset(tess.svars.colors, tr.identityLightByte, numPoints * 2 * sizeof(color4ub_t));
@ -1481,7 +1481,7 @@ void R_DebugPolygon( int color, int numPoints, float *points ) {
vk_shade_geometry(vk.surface_debug_pipeline_outline, false, Vk_Depth_Range::force_zero, false);
dx_bind_geometry();
dx_shade_geometry(dx.surface_debug_pipeline_state_outline, false, Vk_Depth_Range::force_zero, false, true);
dx_shade_geometry(dx.surface_debug_pipeline_outline, false, Vk_Depth_Range::force_zero, false, true);
tess.numVertexes = 0;
}

View File

@ -125,8 +125,8 @@ static void DrawTris (shaderCommands_t *input) {
// DX12
if (dx.active) {
Com_Memset(tess.svars.colors, tr.identityLightByte, tess.numVertexes * 4 );
auto pipeline_state = backEnd.viewParms.isMirror ? dx.tris_mirror_debug_pipeline_state : dx.tris_debug_pipeline_state;
dx_shade_geometry(pipeline_state, false, Vk_Depth_Range::force_zero, true, false);
auto pipeline = backEnd.viewParms.isMirror ? dx.tris_mirror_debug_pipeline : dx.tris_debug_pipeline;
dx_shade_geometry(pipeline, false, Vk_Depth_Range::force_zero, true, false);
}
}
@ -184,7 +184,7 @@ static void DrawNormals (shaderCommands_t *input) {
}
if (dx.active) {
dx_bind_geometry();
dx_shade_geometry(dx.normals_debug_pipeline_state, false, Vk_Depth_Range::force_zero, false, true);
dx_shade_geometry(dx.normals_debug_pipeline, false, Vk_Depth_Range::force_zero, false, true);
}
i += count;
@ -415,8 +415,8 @@ static void ProjectDlightTexture( void ) {
// DX12
if (dx.active) {
auto pipeline_state = dx.dlight_pipeline_states[dl->additive > 0 ? 1 : 0][tess.shader->cullType][tess.shader->polygonOffset];
dx_shade_geometry(pipeline_state, false, Vk_Depth_Range::normal, true, false);
auto pipeline = dx.dlight_pipelines[dl->additive > 0 ? 1 : 0][tess.shader->cullType][tess.shader->polygonOffset];
dx_shade_geometry(pipeline, false, Vk_Depth_Range::normal, true, false);
}
}
}
@ -467,8 +467,8 @@ static void RB_FogPass( void ) {
// DX12
if (dx.active) {
assert(tess.shader->fogPass > 0);
auto pipeline_state = dx.fog_pipeline_states[tess.shader->fogPass - 1][tess.shader->cullType][tess.shader->polygonOffset];
dx_shade_geometry(pipeline_state, false, Vk_Depth_Range::normal, true, false);
auto pipeline = dx.fog_pipelines[tess.shader->fogPass - 1][tess.shader->cullType][tess.shader->polygonOffset];
dx_shade_geometry(pipeline, false, Vk_Depth_Range::normal, true, false);
}
}
@ -849,11 +849,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
// DX12
if (dx.active) {
ID3D12PipelineState* pipeline_state = pStage->dx_pipeline_state;
ID3D12PipelineState* pipeline = pStage->dx_pipeline;
if (backEnd.viewParms.isMirror)
pipeline_state = pStage->dx_mirror_pipeline_state;
pipeline = pStage->dx_mirror_pipeline;
else if (backEnd.viewParms.isPortal)
pipeline_state = pStage->dx_portal_pipeline_state;
pipeline = pStage->dx_portal_pipeline;
Vk_Depth_Range depth_range = Vk_Depth_Range::normal;
if (input->shader->isSky) {
@ -864,7 +864,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
depth_range = Vk_Depth_Range::weapon;
}
dx_shade_geometry(pipeline_state, multitexture, depth_range, true, false);
dx_shade_geometry(pipeline, multitexture, depth_range, true, false);
}
// allow skipping out to show just lightmaps during development

View File

@ -2185,21 +2185,21 @@ static shader_t *FinishShader( void ) {
if (vk.active)
pStage->vk_pipeline = vk_find_pipeline(def);
if (dx.active)
pStage->dx_pipeline_state = dx_find_pipeline(def);
pStage->dx_pipeline = dx_find_pipeline(def);
def.clipping_plane = true;
def.mirror = false;
if (vk.active)
pStage->vk_portal_pipeline = vk_find_pipeline(def);
if (dx.active)
pStage->dx_portal_pipeline_state = dx_find_pipeline(def);
pStage->dx_portal_pipeline = dx_find_pipeline(def);
def.clipping_plane = true;
def.mirror = true;
if (vk.active)
pStage->vk_mirror_pipeline = vk_find_pipeline(def);
if (dx.active)
pStage->dx_mirror_pipeline_state = dx_find_pipeline(def);
pStage->dx_mirror_pipeline = dx_find_pipeline(def);
}
}

View File

@ -115,7 +115,7 @@ static void R_GL_RenderShadowEdges() {
// VULKAN
// DX12
static void R_Vk_Dx_RenderShadowEdges(VkPipeline vk_pipeline, ID3D12PipelineState* dx_pipeline_state) {
static void R_Vk_Dx_RenderShadowEdges(VkPipeline vk_pipeline, ID3D12PipelineState* dx_pipeline) {
if (!vk.active && !dx.active)
return;
@ -150,7 +150,7 @@ static void R_Vk_Dx_RenderShadowEdges(VkPipeline vk_pipeline, ID3D12PipelineStat
}
if (dx.active) {
dx_bind_geometry();
dx_shade_geometry(dx_pipeline_state, false, Vk_Depth_Range::normal, true, false);
dx_shade_geometry(dx_pipeline, false, Vk_Depth_Range::normal, true, false);
}
i += count;
@ -252,8 +252,8 @@ void RB_ShadowTessEnd( void ) {
// VULKAN
// DX12
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[0][1], dx.shadow_volume_pipeline_states[0][1]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[1][1], dx.shadow_volume_pipeline_states[1][1]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[0][1], dx.shadow_volume_pipelines[0][1]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[1][1], dx.shadow_volume_pipelines[1][1]);
} else {
qglCullFace( GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
@ -265,8 +265,8 @@ void RB_ShadowTessEnd( void ) {
// VULKAN
// DX12
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[0][0], dx.shadow_volume_pipeline_states[0][0]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[1][0], dx.shadow_volume_pipeline_states[1][0]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[0][0], dx.shadow_volume_pipelines[0][0]);
R_Vk_Dx_RenderShadowEdges(vk.shadow_volume_pipelines[1][0], dx.shadow_volume_pipelines[1][0]);
}
qglDisable(GL_STENCIL_TEST);
@ -366,7 +366,7 @@ void RB_ShadowFinish( void ) {
dx_world.modelview_transform[15] = 1.0f;
dx_bind_geometry();
dx_shade_geometry(dx.shadow_finish_pipeline_state, false, Vk_Depth_Range::normal, true, false);
dx_shade_geometry(dx.shadow_finish_pipeline, false, Vk_Depth_Range::normal, true, false);
Com_Memcpy(dx_world.modelview_transform, tmp, 64);
}

View File

@ -501,7 +501,7 @@ static void DrawSkyBox( shader_t *shader )
}
if (dx.active) {
dx_bind_geometry();
dx_shade_geometry(dx.skybox_pipeline_state, false, r_showsky->integer ? Vk_Depth_Range::force_zero : Vk_Depth_Range::force_one, true, false);
dx_shade_geometry(dx.skybox_pipeline, false, r_showsky->integer ? Vk_Depth_Range::force_zero : Vk_Depth_Range::force_one, true, false);
}
}
}