15 int xSize,
int ySize,
int zSize,
int numXThreads,
int numYThreads,
int numZThreads)
17 mNumXGroups(xSize/numXThreads),
18 mNumYGroups(ySize/numYThreads),
19 mNumZGroups(zSize/numZThreads)
22 mXMin->SetUsage(Resource::SHADER_OUTPUT);
24 mXMax->SetUsage(Resource::SHADER_OUTPUT);
26 mYMin->SetUsage(Resource::SHADER_OUTPUT);
28 mYMax->SetUsage(Resource::SHADER_OUTPUT);
30 mZMin->SetUsage(Resource::SHADER_OUTPUT);
32 mZMax->SetUsage(Resource::SHADER_OUTPUT);
34 int i = factory->GetAPI();
35 factory->PushDefines();
36 factory->defines.Set(
"USE_COPY_X_FACE", 1);
37 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
38 factory->defines.Set(
"NUM_Z_THREADS", numZThreads);
46 factory->defines.Clear();
47 factory->defines.Set(
"USE_WRITE_X_FACE", 1);
48 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
49 factory->defines.Set(
"NUM_Z_THREADS", numZThreads);
57 factory->defines.Clear();
58 factory->defines.Set(
"USE_COPY_Y_FACE", 1);
59 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
60 factory->defines.Set(
"NUM_Z_THREADS", numZThreads);
68 factory->defines.Clear();
69 factory->defines.Set(
"USE_WRITE_Y_FACE", 1);
70 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
71 factory->defines.Set(
"NUM_Z_THREADS", numZThreads);
79 factory->defines.Clear();
80 factory->defines.Set(
"USE_COPY_Z_FACE", 1);
81 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
82 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
90 factory->defines.Clear();
91 factory->defines.Set(
"USE_WRITE_Z_FACE", 1);
92 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
93 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
101 factory->PopDefines();
105 std::shared_ptr<Texture3>
const& state)
109 mCopyXFace->GetCShader()->Set(
"state", state);
119 mCopyYFace->GetCShader()->Set(
"state", state);
129 mCopyZFace->GetCShader()->Set(
"state", state);
140 "#if USE_COPY_X_FACE\n" 141 "layout(rgba32f) uniform readonly image3D state;\n" 142 "layout(rg32f) uniform writeonly image2D xMin;\n" 143 "layout(rg32f) uniform writeonly image2D xMax;\n" 145 "layout (local_size_x = 1, local_size_y = NUM_Y_THREADS, local_size_z = NUM_Z_THREADS) in;\n" 148 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 149 " ivec3 dim = imageSize(state);\n" 150 " vec2 xMinValue = imageLoad(state, ivec3(1, c.y, c.z)).yz;\n" 151 " vec2 xMaxValue = imageLoad(state, ivec3(dim.x - 2, c.y, c.z)).yz;\n" 152 " imageStore(xMin, c.yz, vec4(xMinValue, 0.0f, 0.0f));\n" 153 " imageStore(xMax, c.yz, vec4(xMaxValue, 0.0f, 0.0f));\n" 157 "#if USE_WRITE_X_FACE\n" 158 "layout(rg32f) uniform readonly image2D xMin;\n" 159 "layout(rg32f) uniform readonly image2D xMax;\n" 160 "layout(rgba32f) uniform writeonly image3D state;\n" 162 "layout (local_size_x = 1, local_size_y = NUM_Y_THREADS, local_size_z = NUM_Z_THREADS) in;\n" 165 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 166 " ivec3 dim = imageSize(state);\n" 167 " vec2 xMinValue = imageLoad(xMin, c.yz).xy;\n" 168 " vec2 xMaxValue = imageLoad(xMax, c.yz).xy;\n" 169 " imageStore(state, ivec3(0, c.y, c.z), vec4(0.0f, xMinValue.x, xMinValue.y, 0.0f));\n" 170 " imageStore(state, ivec3(dim.x - 1, c.y, c.z), vec4(0.0f, xMaxValue.x, xMaxValue.y, 0.0f));\n" 174 "#if USE_COPY_Y_FACE\n" 175 "layout(rgba32f) uniform readonly image3D state;\n" 176 "layout(rg32f) uniform writeonly image2D yMin;\n" 177 "layout(rg32f) uniform writeonly image2D yMax;\n" 179 "layout (local_size_x = NUM_X_THREADS, local_size_y = 1, local_size_z = NUM_Z_THREADS) in;\n" 182 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 183 " ivec3 dim = imageSize(state);\n" 184 " vec2 yMinValue = imageLoad(state, ivec3(c.x, 1, c.z)).xz;\n" 185 " vec2 yMaxValue = imageLoad(state, ivec3(c.x, dim.y - 2, c.z)).xz;\n" 186 " imageStore(yMin, c.xz, vec4(yMinValue, 0.0f, 0.0f));\n" 187 " imageStore(yMax, c.xz, vec4(yMaxValue, 0.0f, 0.0f));\n" 191 "#if USE_WRITE_Y_FACE\n" 192 "layout(rg32f) uniform readonly image2D yMin;\n" 193 "layout(rg32f) uniform readonly image2D yMax;\n" 194 "layout(rgba32f) uniform writeonly image3D state;\n" 196 "layout (local_size_x = NUM_X_THREADS, local_size_y = 1, local_size_z = NUM_Z_THREADS) in;\n" 199 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 200 " ivec3 dim = imageSize(state);\n" 201 " vec2 yMinValue = imageLoad(yMin, c.xz).xy;\n" 202 " vec2 yMaxValue = imageLoad(yMax, c.xz).xy;\n" 203 " imageStore(state, ivec3(c.x, 0, c.z), vec4(yMinValue.x, 0.0f, yMinValue.y, 0.0f));\n" 204 " imageStore(state, ivec3(c.x, dim.y - 1, c.z), vec4(yMaxValue.x, 0.0f, yMaxValue.y, 0.0f));\n" 208 "#if USE_COPY_Z_FACE\n" 209 "layout(rgba32f) uniform readonly image3D state;\n" 210 "layout(rg32f) uniform writeonly image2D zMin;\n" 211 "layout(rg32f) uniform writeonly image2D zMax;\n" 213 "layout (local_size_x = NUM_X_THREADS, local_size_y = NUM_Y_THREADS, local_size_z = 1) in;\n" 216 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 217 " ivec3 dim = imageSize(state);\n" 218 " vec2 zMinValue = imageLoad(state, ivec3(c.x, c.y, 1)).xy;\n" 219 " vec2 zMaxValue = imageLoad(state, ivec3(c.x, c.y, dim.z - 2)).xy;\n" 220 " imageStore(zMin, c.xy, vec4(zMinValue, 0.0f, 0.0f));\n" 221 " imageStore(zMax, c.xy, vec4(zMaxValue, 0.0f, 0.0f));\n" 225 "#if USE_WRITE_Z_FACE\n" 226 "layout(rg32f) uniform readonly image2D zMin;\n" 227 "layout(rg32f) uniform readonly image2D zMax;\n" 228 "layout(rgba32f) uniform writeonly image3D state;\n" 230 "layout (local_size_x = NUM_X_THREADS, local_size_y = NUM_Y_THREADS, local_size_z = 1) in;\n" 233 " ivec3 c = ivec3(gl_GlobalInvocationID.xyz);\n" 234 " ivec3 dim = imageSize(state);\n" 235 " vec2 zMinValue = imageLoad(zMin, c.xy).xy;\n" 236 " vec2 zMaxValue = imageLoad(zMax, c.xy).xy;\n" 237 " imageStore(state, ivec3(c.x, c.y, 0), vec4(zMinValue.x, zMinValue.y, 0.0f, 0.0f));\n" 238 " imageStore(state, ivec3(c.x, c.y, dim.z - 1), vec4(zMaxValue.x, zMaxValue.y, 0.0f, 0.0f));\n" 243 "#if USE_COPY_X_FACE\n" 244 "Texture3D<float4> state;\n" 245 "RWTexture2D<float2> xMin;\n" 246 "RWTexture2D<float2> xMax;\n" 248 "[numthreads(1, NUM_Y_THREADS, NUM_Z_THREADS)]\n" 249 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 252 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 253 " xMin[c.yz] = state[uint3(1, c.y, c.z)].yz;\n" 254 " xMax[c.yz] = state[uint3(dim.x - 2, c.y, c.z)].yz;\n" 258 "#if USE_WRITE_X_FACE\n" 259 "Texture2D<float2> xMin;\n" 260 "Texture2D<float2> xMax;\n" 261 "RWTexture3D<float4> state;\n" 263 "[numthreads(1, NUM_Y_THREADS, NUM_Z_THREADS)]\n" 264 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 267 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 268 " state[uint3(0, c.y, c.z)] = float4(0.0f, xMin[c.yz].x, xMin[c.yz].y, 0.0f);\n" 269 " state[uint3(dim.x - 1, c.y, c.z)] = float4(0.0f, xMax[c.yz].x, xMax[c.yz].y, 0.0f);\n" 273 "#if USE_COPY_Y_FACE\n" 274 "Texture3D<float4> state;\n" 275 "RWTexture2D<float2> yMin;\n" 276 "RWTexture2D<float2> yMax;\n" 278 "[numthreads(NUM_X_THREADS, 1, NUM_Z_THREADS)]\n" 279 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 282 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 283 " yMin[c.xz] = state[uint3(c.x, 1, c.z)].xz;\n" 284 " yMax[c.xz] = state[uint3(c.x, dim.y - 2, c.z)].xz;\n" 288 "#if USE_WRITE_Y_FACE\n" 289 "Texture2D<float2> yMin;\n" 290 "Texture2D<float2> yMax;\n" 291 "RWTexture3D<float4> state;\n" 293 "[numthreads(NUM_X_THREADS, 1, NUM_Z_THREADS)]\n" 294 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 297 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 298 " state[uint3(c.x, 0, c.z)] = float4(yMin[c.xz].x, 0.0f, yMin[c.xz].y, 0.0f);\n" 299 " state[uint3(c.x, dim.y - 1, c.z)] = float4(yMax[c.xz].x, 0.0f, yMax[c.xz].y, 0.0f);\n" 303 "#if USE_COPY_Z_FACE\n" 304 "Texture3D<float4> state;\n" 305 "RWTexture2D<float2> zMin;\n" 306 "RWTexture2D<float2> zMax;\n" 308 "[numthreads(NUM_X_THREADS, NUM_Y_THREADS, 1)]\n" 309 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 312 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 313 " zMin[c.xy] = state[uint3(c.x, c.y, 1)].xy;\n" 314 " zMax[c.xy] = state[uint3(c.x, c.y, dim.z - 2)].xy;\n" 318 "#if USE_WRITE_Z_FACE\n" 319 "Texture2D<float2> zMin;\n" 320 "Texture2D<float2> zMax;\n" 321 "RWTexture3D<float4> state;\n" 323 "[numthreads(NUM_X_THREADS, NUM_Y_THREADS, 1)]\n" 324 "void CSMain(uint3 c : SV_DispatchThreadID)\n" 327 " state.GetDimensions(dim.x, dim.y, dim.z);\n" 328 " state[uint3(c.x, c.y, 0)] = float4(zMin[c.xy].x, zMin[c.xy].y, 0.0f, 0.0f);\n" 329 " state[uint3(c.x, c.y, dim.z - 1)] = float4(zMax[c.xy].x, zMax[c.xy].y, 0.0f, 0.0f);\n" std::shared_ptr< Texture2 > mYMin
std::shared_ptr< Texture2 > mYMax
Fluid3EnforceStateBoundary(std::shared_ptr< ProgramFactory > const &factory, int xSize, int ySize, int zSize, int numXThreads, int numYThreads, int numZThreads)
std::shared_ptr< ComputeProgram > mCopyXFace
std::shared_ptr< ComputeProgram > mCopyZFace
static std::string const msGLSLSource
std::shared_ptr< ComputeProgram > mWriteXFace
GLsizei const GLchar *const * string
std::shared_ptr< Texture2 > mXMax
std::shared_ptr< ComputeProgram > mWriteZFace
std::shared_ptr< Texture2 > mXMin
std::shared_ptr< ComputeProgram > mCopyYFace
static std::string const msHLSLSource
std::shared_ptr< Texture2 > mZMax
std::shared_ptr< Texture2 > mZMin
static std::string const * msSource[ProgramFactory::PF_NUM_API]
void Execute(std::shared_ptr< GraphicsEngine > const &engine, std::shared_ptr< Texture3 > const &state)
std::shared_ptr< ComputeProgram > mWriteYFace