From 58504d8c0b140aa5f097ef32e8ffe467a8d320cd Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 20 Jan 2014 01:13:37 -0800 Subject: [PATCH] Initial pass at pointsprites. Needs a lot more work. --- src/xenia/gpu/d3d11/d3d11_geometry_shader.cc | 37 ++++++++++++++++++++ src/xenia/gpu/d3d11/d3d11_graphics_driver.cc | 12 +++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc b/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc index 1e931f16b..308270f27 100644 --- a/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc +++ b/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc @@ -135,6 +135,43 @@ D3D11PointSpriteGeometryShader::~D3D11PointSpriteGeometryShader() { int D3D11PointSpriteGeometryShader::Generate(D3D11VertexShader* vertex_shader, alloy::StringBuffer* output) { + // TODO(benvanik): fetch default point size from register and use that if + // the VS doesn't write oPointSize. + // TODO(benvanik): clamp to min/max. + // TODO(benvanik): figure out how to see which interpolator gets adjusted. + + output->Append( + "struct VERTEX {\n" + " float4 oPos : SV_POSITION;\n"); + auto alloc_counts = vertex_shader->alloc_counts(); + if (alloc_counts.params) { + output->Append( + " float4 o[%d] : XE_O;\n", + D3D11Shader::MAX_INTERPOLATORS); + } + output->Append( + " float4 oPointSize : PSIZE;\n" + "};\n"); + + output->Append( + "[maxvertexcount(4)]\n" + "void main(point VERTEX input[1], inout TriangleStream output) {\n" + " const float2 offsets[4] = {\n" + " float2(-1.0, 1.0),\n" + " float2( 1.0, 1.0),\n" + " float2(-1.0, -1.0),\n" + " float2( 1.0, -1.0),\n" + " };\n" + " float psize = max(input[0].oPointSize.x, 1.0);\n" + " VERTEX v;\n" + " for (uint n = 0; n < 4; n++) {\n" + " v = input[0];\n" + " v.oPos.xy += offsets[n] * psize;\n" + " output.Append(v);\n" + " }\n" + " output.RestartStrip();\n" + "}\n"); + return 0; } diff --git a/src/xenia/gpu/d3d11/d3d11_graphics_driver.cc b/src/xenia/gpu/d3d11/d3d11_graphics_driver.cc index 28afe138f..c428fbd99 100644 --- a/src/xenia/gpu/d3d11/d3d11_graphics_driver.cc +++ b/src/xenia/gpu/d3d11/d3d11_graphics_driver.cc @@ -139,12 +139,12 @@ int D3D11GraphicsDriver::SetupDraw(XE_GPU_PRIMITIVE_TYPE prim_type) { switch (prim_type) { case XE_GPU_PRIMITIVE_TYPE_POINT_LIST: primitive_topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; - //if (state_.vertex_shader) { - // if (state_.vertex_shader->DemandGeometryShader( - // D3D11VertexShader::POINT_SPRITE_SHADER, &geometry_shader)) { - // return 1; - // } - //} + if (state_.vertex_shader) { + if (state_.vertex_shader->DemandGeometryShader( + D3D11VertexShader::POINT_SPRITE_SHADER, &geometry_shader)) { + return 1; + } + } break; case XE_GPU_PRIMITIVE_TYPE_LINE_LIST: primitive_topology = D3D_PRIMITIVE_TOPOLOGY_LINELIST;