15 int xSize,
int ySize,
int numXThreads,
int numYThreads)
17 mNumXGroups(xSize/numXThreads),
18 mNumYGroups(ySize/numYThreads)
21 mXMin->SetUsage(Resource::SHADER_OUTPUT);
23 mXMax->SetUsage(Resource::SHADER_OUTPUT);
25 mYMin->SetUsage(Resource::SHADER_OUTPUT);
27 mYMax->SetUsage(Resource::SHADER_OUTPUT);
29 int i = factory->GetAPI();
30 factory->PushDefines();
31 factory->defines.Set(
"USE_COPY_X_EDGE", 1);
32 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
40 factory->defines.Clear();
41 factory->defines.Set(
"USE_WRITE_X_EDGE", 1);
42 factory->defines.Set(
"NUM_Y_THREADS", numYThreads);
50 factory->defines.Clear();
51 factory->defines.Set(
"USE_COPY_Y_EDGE", 1);
52 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
60 factory->defines.Clear();
61 factory->defines.Set(
"USE_WRITE_Y_EDGE", 1);
62 factory->defines.Set(
"NUM_X_THREADS", numXThreads);
70 factory->PopDefines();
74 std::shared_ptr<Texture2>
const& state)
99 "#if USE_COPY_X_EDGE\n" 100 "layout(rgba32f) uniform readonly image2D state;\n" 101 "layout(r32f) uniform writeonly image1D xMin;\n" 102 "layout(r32f) uniform writeonly image1D xMax;\n" 104 "layout (local_size_x = 1, local_size_y = NUM_Y_THREADS, local_size_z = 1) in;\n" 107 " ivec2 c = ivec2(gl_GlobalInvocationID.xy);\n" 108 " ivec2 dim = imageSize(state);\n" 109 " float xMinValue = imageLoad(state, ivec2(1, c.y)).y;\n" 110 " float xMaxValue = imageLoad(state, ivec2(dim.x - 2, c.y)).y;\n" 111 " imageStore(xMin, c.y, vec4(xMinValue, 0.0f, 0.0f, 0.0f));\n" 112 " imageStore(xMax, c.y, vec4(xMaxValue, 0.0f, 0.0f, 0.0f));\n" 116 "#if USE_WRITE_X_EDGE\n" 117 "layout(r32f) uniform readonly image1D xMin;\n" 118 "layout(r32f) uniform readonly image1D xMax;\n" 119 "layout(rgba32f) uniform writeonly image2D state;\n" 121 "layout (local_size_x = 1, local_size_y = NUM_Y_THREADS, local_size_z = 1) in;\n" 124 " ivec2 c = ivec2(gl_GlobalInvocationID.xy);\n" 125 " ivec2 dim = imageSize(state);\n" 126 " float xMinValue = imageLoad(xMin, c.y).x;\n" 127 " float xMaxValue = imageLoad(xMax, c.y).x;\n" 128 " imageStore(state, ivec2(0, c.y), vec4(0.0f, xMinValue, 0.0f, 0.0f));\n" 129 " imageStore(state, ivec2(dim.x - 1, c.y), vec4(0.0f, xMaxValue, 0.0f, 0.0f));\n" 133 "#if USE_COPY_Y_EDGE\n" 134 "layout(rgba32f) uniform readonly image2D state;\n" 135 "layout(r32f) uniform writeonly image1D yMin;\n" 136 "layout(r32f) uniform writeonly image1D yMax;\n" 138 "layout (local_size_x = NUM_X_THREADS, local_size_y = 1, local_size_z = 1) in;\n" 141 " ivec2 c = ivec2(gl_GlobalInvocationID.xy);\n" 142 " ivec2 dim = imageSize(state);\n" 143 " float yMinValue = imageLoad(state, ivec2(c.x, 1)).x;\n" 144 " float yMaxValue = imageLoad(state, ivec2(c.x, dim.y - 2)).x;\n" 145 " imageStore(yMin, c.x, vec4(yMinValue, 0.0f, 0.0f, 0.0f));\n" 146 " imageStore(yMax, c.x, vec4(yMaxValue, 0.0f, 0.0f, 0.0f));\n" 150 "#if USE_WRITE_Y_EDGE\n" 151 "layout(r32f) uniform readonly image1D yMin;\n" 152 "layout(r32f) uniform readonly image1D yMax;\n" 153 "layout(rgba32f) uniform writeonly image2D state;\n" 155 "layout (local_size_x = NUM_X_THREADS, local_size_y = 1, local_size_z = 1) in;\n" 158 " ivec2 c = ivec2(gl_GlobalInvocationID.xy);\n" 159 " ivec2 dim = imageSize(state);\n" 160 " float yMinValue = imageLoad(yMin, c.x).x;\n" 161 " float yMaxValue = imageLoad(yMax, c.x).x;\n" 162 " imageStore(state, ivec2(c.x, 0), vec4(yMinValue, 0.0f, 0.0f, 0.0f));\n" 163 " imageStore(state, ivec2(c.x, dim.y - 1), vec4(yMaxValue, 0.0f, 0.0f, 0.0f));\n" 168 "#if USE_COPY_X_EDGE\n" 169 "Texture2D<float4> state;\n" 170 "RWTexture1D<float> xMin;\n" 171 "RWTexture1D<float> xMax;\n" 173 "[numthreads(1, NUM_Y_THREADS, 1)]\n" 174 "void CSMain(uint2 c : SV_DispatchThreadID)\n" 177 " state.GetDimensions(dim.x, dim.y);\n" 178 " xMin[c.y] = state[uint2(1, c.y)].y;\n" 179 " xMax[c.y] = state[uint2(dim.x - 2, c.y)].y;\n" 183 "#if USE_WRITE_X_EDGE\n" 184 "Texture1D<float> xMin;\n" 185 "Texture1D<float> xMax;\n" 186 "RWTexture2D<float4> state;\n" 188 "[numthreads(1, NUM_Y_THREADS, 1)]\n" 189 "void CSMain(uint2 c : SV_DispatchThreadID)\n" 192 " state.GetDimensions(dim.x, dim.y);\n" 193 " state[uint2(0, c.y)] = float4(0.0f, xMin[c.y], 0.0f, 0.0f);\n" 194 " state[uint2(dim.x - 1, c.y)] = float4(0.0f, xMax[c.y], 0.0f, 0.0f);\n" 198 "#if USE_COPY_Y_EDGE\n" 199 "Texture2D<float4> state;\n" 200 "RWTexture1D<float> yMin;\n" 201 "RWTexture1D<float> yMax;\n" 203 "[numthreads(NUM_X_THREADS, 1, 1)]\n" 204 "void CSMain(uint2 c : SV_DispatchThreadID)\n" 207 " state.GetDimensions(dim.x, dim.y);\n" 208 " yMin[c.x] = state[uint2(c.x, 1)].x;\n" 209 " yMax[c.x] = state[uint2(c.x, dim.y - 2)].x;\n" 213 "#if USE_WRITE_Y_EDGE\n" 214 "Texture1D<float> yMin;\n" 215 "Texture1D<float> yMax;\n" 216 "RWTexture2D<float4> state;\n" 218 "[numthreads(NUM_X_THREADS, 1, 1)]\n" 219 "void CSMain(uint2 c : SV_DispatchThreadID)\n" 222 " state.GetDimensions(dim.x, dim.y);\n" 223 " state[uint2(c.x, 0)] = float4(yMin[c.x], 0.0f, 0.0f, 0.0f);\n" 224 " state[uint2(c.x, dim.y - 1)] = float4(yMax[c.x], 0.0f, 0.0f, 0.0f);\n" static std::string const msGLSLSource
std::shared_ptr< ComputeProgram > mCopyXEdge
std::shared_ptr< ComputeProgram > mWriteXEdge
std::shared_ptr< Texture1 > mYMax
std::shared_ptr< ComputeProgram > mWriteYEdge
GLsizei const GLchar *const * string
static std::string const msHLSLSource
Fluid2EnforceStateBoundary(std::shared_ptr< ProgramFactory > const &factory, int xSize, int ySize, int numXThreads, int numYThreads)
std::shared_ptr< Texture1 > mXMin
std::shared_ptr< ComputeProgram > mCopyYEdge
std::shared_ptr< Texture1 > mXMax
static std::string const * msSource[ProgramFactory::PF_NUM_API]
std::shared_ptr< Texture1 > mYMin
void Execute(std::shared_ptr< GraphicsEngine > const &engine, std::shared_ptr< Texture2 > const &state)