Add HW bounding Box support to d3d backend

This commit is contained in:
Rodolfo Bogado
2014-12-04 23:01:20 -03:00
parent c617b6c722
commit 93b4540e19
9 changed files with 211 additions and 16 deletions

View File

@ -261,11 +261,20 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
if (g_ActiveConfig.backend_info.bSupportsBBox)
{
out.Write(
"layout(std140, binding = 3) buffer BBox {\n"
"\tint4 bbox_data;\n"
"};\n"
);
if (ApiType == API_OPENGL)
{
out.Write(
"layout(std140, binding = 3) buffer BBox {\n"
"\tint4 bbox_data;\n"
"};\n"
);
}
else
{
out.Write(
"globallycoherent RWBuffer<int> bbox_data : register(u2);\n"
);
}
}
GenerateVSOutputStruct(out, ApiType);
@ -582,12 +591,24 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
if (g_ActiveConfig.backend_info.bSupportsBBox && BoundingBox::active)
{
uid_data->bounding_box = true;
out.Write(
"\tif(bbox_data.x > int(gl_FragCoord.x)) atomicMin(bbox_data.x, int(gl_FragCoord.x));\n"
"\tif(bbox_data.y < int(gl_FragCoord.x)) atomicMax(bbox_data.y, int(gl_FragCoord.x));\n"
"\tif(bbox_data.z > int(gl_FragCoord.y)) atomicMin(bbox_data.z, int(gl_FragCoord.y));\n"
"\tif(bbox_data.w < int(gl_FragCoord.y)) atomicMax(bbox_data.w, int(gl_FragCoord.y));\n"
);
if (ApiType == API_OPENGL)
{
out.Write(
"\tif(bbox_data.x > int(gl_FragCoord.x)) atomicMin(bbox_data.x, int(gl_FragCoord.x));\n"
"\tif(bbox_data.y < int(gl_FragCoord.x)) atomicMax(bbox_data.y, int(gl_FragCoord.x));\n"
"\tif(bbox_data.z > int(gl_FragCoord.y)) atomicMin(bbox_data.z, int(gl_FragCoord.y));\n"
"\tif(bbox_data.w < int(gl_FragCoord.y)) atomicMax(bbox_data.w, int(gl_FragCoord.y));\n"
);
}
else
{
out.Write(
"\tif(bbox_data[0] > int(rawpos.x)) InterlockedMin(bbox_data[0], int(rawpos.x));\n"
"\tif(bbox_data[1] < int(rawpos.x)) InterlockedMax(bbox_data[1], int(rawpos.x));\n"
"\tif(bbox_data[2] > int(rawpos.y)) InterlockedMin(bbox_data[2], int(rawpos.y));\n"
"\tif(bbox_data[3] < int(rawpos.y)) InterlockedMax(bbox_data[3], int(rawpos.y));\n"
);
}
}
out.Write("}\n");