コード例 #1
0
tcu::TestNode::IterateResult ShaderAtomicCounterOpsTestBase::iterate()
{
	if (!m_context.getContextInfo().isExtensionSupported("GL_ARB_shader_atomic_counters") ||
		!m_context.getContextInfo().isExtensionSupported("GL_ARB_shader_atomic_counter_ops"))
	{
		m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported");
		return STOP;
	}

	for (ShaderPipelineIter iter = m_shaderPipelines.begin(); iter != m_shaderPipelines.end(); ++iter)
	{
		fillAtomicCounterBuffer(iter->getAtomicOperation());
		bindBuffers();
		iter->test(m_context);

		bool		operationValueValid = checkAtomicCounterBuffer(iter->getAtomicOperation());
		std::string operationFailMsg	= "Result of atomic operation was different than expected (" +
									   iter->getAtomicOperation()->getFunction() + ").";
		TCU_CHECK_MSG(operationValueValid, operationFailMsg.c_str());

		bool		returnValueValid = validateScreenPixels(tcu::Vec4(1.0f), tcu::Vec4(0.5f));
		std::string returnFailMsg	= "Result of atomic operation return value was different than expected (" +
									iter->getAtomicOperation()->getFunction() + ").";
		TCU_CHECK_MSG(returnValueValid, returnFailMsg.c_str());
	}

	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
	return STOP;
}
コード例 #2
0
void oclFluid3D::setParticleCount(size_t iSize)
{
	// JSTIER make sure mParticleCount is a mutliple of cLocalSize

	mParticleCount = iSize;

    bfCell.resize<cl_uint>(mParticleCount);
    bfCellStart.resize<cl_uint>(cBucketCount);
    bfCellEnd.resize<cl_uint>(cBucketCount);
    bfIndex.resize<cl_uint>(mParticleCount);
    bfSortedPosition.resize<cl_float4>(mParticleCount);
    bfSortedVelocity.resize<cl_float4>(mParticleCount);

	bfPosition->resize<cl_float4>(mParticleCount);
	if (bfPosition->getOwner<oclObject>() != this)
	{
		Log(WARN, this) << " resizing buffer " <<  bfPosition->getName() << " to " << mParticleCount;
	}

	bfVelocity->resize<cl_float4>(mParticleCount);
	if (bfVelocity->getOwner<oclObject>() != this)
	{
		Log(WARN, this) << " resizing buffer " <<  bfVelocity->getName() << " to " << mParticleCount;
	}

	bfForce->resize<cl_float4>(mParticleCount);
	if (bfForce->getOwner<oclObject>() != this)
	{
		Log(WARN, this) << " resizing buffer " <<  bfForce->getName() << " to " << mParticleCount;
	}

	bindBuffers();
}
コード例 #3
0
int oclFluid3D::setForceBuffer(oclBuffer* iBuffer)
{
	if (iBuffer->count<cl_float4>() < mParticleCount)
	{
		iBuffer->resize<cl_float4>(mParticleCount);
		Log(WARN, this) << " libCL is resizing buffer " <<  iBuffer->getName() << " to " << mParticleCount;
	}
	deleteBuffer(bfForce);
	bfForce = iBuffer;
	return bindBuffers();
}
コード例 #4
0
int oclFluid3D::setPositionBuffer(oclBuffer* iBuffer)
{
	if (iBuffer->count<cl_float4>() != mParticleCount)
	{
		iBuffer->resize<cl_float4>(mParticleCount);
		Log(WARN, this) << " resizing buffer " <<  iBuffer->getName() << " to " << mParticleCount;
	}
	deleteBuffer(bfPosition);
	bfPosition = iBuffer;
	return bindBuffers();
}
コード例 #5
0
ファイル: GeometryRenderer.cpp プロジェクト: SvetZari/QtAV
void GeometryRenderer::render()
{
    if (!g)
        return;
    bindBuffers();
    if (g->indexCount() > 0) {
        DYGL(glDrawElements(g->primitive(), g->indexCount(), g->indexType(), ibo.isCreated() ? NULL : g->indexData())); // null: data in vao or ibo. not null: data in memory
    } else {
        DYGL(glDrawArrays(g->primitive(), 0, g->vertexCount()));
    }
    unbindBuffers();
}
コード例 #6
0
int oclFluid3D::compile()
{
	clInitFluid = 0;
	clIntegrateForce = 0;
	clIntegrateVelocity = 0;
	clHash = 0;
	clReorder = 0;
	clInitBounds = 0;

	if (!mRadixSort.compile())
	{
		return 0;
	}

	if (!oclProgram::compile())
	{
		return 0;
	}

	clInitFluid = createKernel("clInitFluid");
	KERNEL_VALIDATE(clInitFluid)
	clIntegrateForce = createKernel("clIntegrateForce");
	KERNEL_VALIDATE(clIntegrateForce)
	clIntegrateVelocity = createKernel("clIntegrateVelocity");
	KERNEL_VALIDATE(clIntegrateVelocity)
	clHash = createKernel("clHash");
	KERNEL_VALIDATE(clHash)
	clReorder = createKernel("clReorder");
	KERNEL_VALIDATE(clReorder)
	clInitBounds = createKernel("clInitBounds");
	KERNEL_VALIDATE(clInitBounds)
	clFindBounds = createKernel("clFindBounds");
	KERNEL_VALIDATE(clFindBounds)
	clCalculateDensity = createKernel("clCalculateDensity");
	KERNEL_VALIDATE(clCalculateDensity)
	clCalculateForces = createKernel("clCalculateForces");
	KERNEL_VALIDATE(clCalculateForces)
	clGravity = createKernel("clGravity");
	KERNEL_VALIDATE(clGravity)
	clClipBox = createKernel("clClipBox");
	KERNEL_VALIDATE(clClipBox)

	// init fluid parameters
	clSetKernelArg(clInitFluid, 0, sizeof(cl_mem), bfParams);
	clEnqueueTask(mContext.getDevice(0), clInitFluid, 0, NULL, clInitFluid.getEvent());
	bfParams.map(CL_MAP_READ);

	return bindBuffers();
}
コード例 #7
0
        Render::Render()
        {
            glGenVertexArrays(1, &VertexArrayID);
            glBindVertexArray(VertexArrayID);

            glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

            shader = new Shader("TransformVertexShader.vertexshader",
                                "TextureFragmentShader.fragmentshader");

            color_location = glGetUniformLocation(shader->getProgramID(), "color");
            if (color_location == -1) throw std::string("Uniform color variable not found.\n");

            fillBuffers();
            bindBuffers();
        }
コード例 #8
0
ファイル: trackball.hpp プロジェクト: mseefelder/tucano
    /**
     * @brief Renders the trackball representation.
     * @todo setTrackballOrthographicMatrix should be set during viewport resize
     */
    void render (void)
    {
        if(drawTrackball)
        {

            float ratio = (viewport[2] - viewport[0]) / (viewport[3] - viewport[1]);
            setTrackballOrthographicMatrix(-ratio, ratio, -1.0, 1.0, 0.1, 100.0);

            trackball_shader.bind();

            //Using unique viewMatrix for the trackball, considering only the rotation to be visualized.
            Eigen::Affine3f trackballViewMatrix = Eigen::Affine3f::Identity();
            trackballViewMatrix.translate(defaultTranslation);
            trackballViewMatrix.rotate(quaternion);

            trackball_shader.setUniform("viewMatrix", trackballViewMatrix);
            trackball_shader.setUniform("projectionMatrix", trackballProjectionMatrix);
            trackball_shader.setUniform("nearPlane", near_plane);
            trackball_shader.setUniform("farPlane", far_plane);

            bindBuffers();

            //X:
            Eigen::Vector4f colorVector(1.0, 0.0, 0.0, 1.0);
            trackball_shader.setUniform("modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(0.0,1.0,0.0)));
            trackball_shader.setUniform("in_Color", colorVector);
            glDrawArrays(GL_LINE_LOOP, 0, 200);

            //Y:
            colorVector << 0.0, 1.0, 0.0, 1.0;
            trackball_shader.setUniform("modelMatrix", Eigen::Affine3f::Identity()*Eigen::AngleAxis<float>(M_PI/2.0,Eigen::Vector3f(1.0,0.0,0.0)));
            trackball_shader.setUniform("in_Color", colorVector);
            glDrawArrays(GL_LINE_LOOP, 0, 200);

            //Z:
            colorVector << 0.0, 0.0, 1.0, 1.0;            
            trackball_shader.setUniform("modelMatrix", Eigen::Affine3f::Identity());
            trackball_shader.setUniform("in_Color", colorVector);
            glDrawArrays(GL_LINE_LOOP, 0, 200);

            unbindBuffers();

            trackball_shader.unbind();
        }
    }
コード例 #9
0
ファイル: Clouds.cpp プロジェクト: Atyansh/deerstalker
void Clouds::draw(DrawData& data) {

	float time = clock() / float(CLOCKS_PER_SEC);
	float delta = time - prevTime;
	prevTime = time;
	currCloudTime += min(delta, 0.05f);

	updateScene(min(delta, 0.05f), currCloudTime);
	shader->bind();

	glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(data.matrix));
	glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(data.view));
	glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(data.projection));
	glUniform3fv(expansionDirectionLoc, 1, glm::value_ptr(expansionDirection));
	glUniform1f(timeLoc, currCloudTime * MORPHING_SPEED_PER_SECOND);

	glBindVertexArray(this->VAO);
	bindBuffers();
	glDrawElementsInstanced(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, NULL, offsets.size());
	glBindVertexArray(0);

	shader->unbind();
}
コード例 #10
0
ファイル: object.cpp プロジェクト: Omarasifshaikh/weatherViz
Object::Object() { bindBuffers(); }
コード例 #11
0
ファイル: object.cpp プロジェクト: Omarasifshaikh/weatherViz
Object::Object(std::vector <glm::vec3> vertices, std::vector <glm::vec2> uvs, std::vector <glm::vec3> normals, std::vector <unsigned short> index, Material* mat, glm::vec3 position, glm::quat rotation) : vertexIndex(vertices), uvIndex(uvs), normalIndex(normals), indices(index), material(mat), position(position), rotation(rotation) { bindBuffers(); }
コード例 #12
0
ファイル: object.cpp プロジェクト: Omarasifshaikh/weatherViz
Object::Object(std::vector <glm::vec3> vertices, std::vector <glm::vec2> uvs, std::vector <glm::vec3> normals, std::vector <unsigned short> index, Material* mat) : vertexIndex(vertices), uvIndex(uvs), normalIndex(normals), indices(index), material(mat) { bindBuffers(); }
コード例 #13
0
ファイル: object.cpp プロジェクト: Omarasifshaikh/weatherViz
Object::Object(glm::vec3 position, glm::quat rotation) : position(position), rotation(rotation) { bindBuffers(); }
コード例 #14
0
ファイル: RenderDevice.cpp プロジェクト: FloodProject/flood
void RenderDevice::render( const RenderState& state, const LightQueue& lights )
{
    BufferManager* buffers = activeContext->bufferManager;
    ProgramManager* programs = activeContext->programManager;
    
    RenderBatch* renderable = state.renderable;
    bindBuffers(renderable);

    const GeometryBuffer* gb = renderable->getGeometryBuffer().get();
    if( gb->data.Empty() ) return;

    BufferEntry* bufs = buffers->getBuffer(gb);

    // Setup the vertex buffer format.
    VertexBuffer* vb = bufs->vb.get();
    renderBackend->setupVertexBuffer(vb);
    
    Material* material = state.material;
    ShaderMaterial* shader = material->getShader().Resolve();

    ShaderProgram* shaderProgram = programs->getProgram(shader);
    if( !shaderProgram ) return;

    if( !shaderProgram->isLinked() && !shaderProgram->link() )
        return;

    shaderProgram->bind();

    renderBackend->setupRenderState(state, true);
    bindTextureUnits(state, true);

    if( !renderable->onPreRender.empty() )
    {
        // Call the user pre render hook.
        renderable->onPreRender(activeView, state);
    }

    RenderLayer stage = renderable->getRenderLayer();

    if( stage != RenderLayer::Overlays )
    {
        if( !setupRenderStateMatrix(state) )
            return;

        //if( !setupRenderStateLight(state, lights) )
        //  return;
    }
    else if( stage == RenderLayer::Overlays )
    {
        if( !setupRenderStateOverlay(state) )
            return;
    }

    UniformBuffer* ub = renderable->getUniformBuffer().get();
    shaderProgram->setUniforms(ub);

    renderBackend->renderBatch(renderable);
    
    if( !renderable->onPostRender.empty() )
    {
        // Call the user post render hook.
        renderable->onPostRender(activeView, state);
    }
    
    renderBackend->unsetupRenderState(state);
    unbindTextureUnits(state.material);
    
    shaderProgram->unbind();

    renderBackend->unbindVertexBuffer(vb);
    unbindBuffers(renderable);
}