예제 #1
0
void RenderState::saveTexture(int i, WCHAR* path) {
    LPDIRECT3DBASETEXTURE9 texture = NULL;
    if (FAILED(getDevice()->GetTexture(i, &texture))) {
        MM_LOG_INFO(format("Failed to query texture for stage: {}", i));
    } else if (!texture) {
        MM_LOG_INFO(format("Failed to obtain texture for stage {}; texture is null", i));
    } else {
        LPDIRECT3DBASETEXTURE9 snaptex = texture;
        if (texture == getSelectionTexture()) {
            // no point in snapping this
            snaptex = currentTexture();
        }

        // TODO: this will fail for textures in the default pool that are dynamic.  will probably need to force managed
        // pool when in snapshot mode for games that are affected by this.
        if (FAILED(D3DXSaveTextureToFileW(
                       path,
                       D3DXIFF_DDS,
                       snaptex,
                       NULL))) {
            MM_LOG_INFO(format("Failed to save texture {}", i));
        }
        texture->Release();
    }
}
예제 #2
0
////////////////////////////////////////////////////////////////////////////////
//
//  Method: BindlessApp::draw()
//
//    Performs the actual rendering
//
////////////////////////////////////////////////////////////////////////////////
void BindlessApp::draw(void)
{
    nv::matrix4f modelviewMatrix;

    glClearColor( 0.5, 0.5, 0.5, 1.0);
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);

    // Enable the vertex and pixel shader
    m_shader->enable();

	if (m_useBindlessTextures) {
		GLuint samplersLocation(m_shader->getUniformLocation("samplers"));
		glUniform1ui64vNV(samplersLocation, m_numTextures, m_textureHandles);

	}

	GLuint bBindlessTexture(m_shader->getUniformLocation("useBindless"));
	glUniform1i(bBindlessTexture, m_useBindlessTextures);

	GLuint currentTexture(m_shader->getUniformLocation("currentFrame"));
	glUniform1i(currentTexture, m_currentFrame);

    // Set up the transformation matices up
    modelviewMatrix = m_transformer->getModelViewMat();
    m_transformUniformsData.ModelView = modelviewMatrix;
    m_transformUniformsData.ModelViewProjection= m_projectionMatrix * modelviewMatrix;
    m_transformUniformsData.UseBindlessUniforms = m_useBindlessUniforms;
    glBindBufferBase(GL_UNIFORM_BUFFER, 2, m_transformUniforms);
    glNamedBufferSubDataEXT(m_transformUniforms, 0, sizeof(TransformUniforms), &m_transformUniformsData);

    
    // If we are going to update the uniforms every frame, do it now
    if(m_updateUniformsEveryFrame == true)
    {
        float deltaTime;
        float dt;

        deltaTime = getFrameDeltaTime();

        if(deltaTime < m_minimumFrameDeltaTime)
        {
            m_minimumFrameDeltaTime = deltaTime;
        }

        dt = std::min(0.00005f / m_minimumFrameDeltaTime, .01f);
        m_t += dt * (float)Mesh::m_drawCallsPerState;

        updatePerMeshUniforms(m_t);
    }


    // Set up default per mesh uniforms. These may be changed on a per mesh basis in the rendering loop below 
    if(m_useBindlessUniforms == true)
    {
        // *** INTERESTING ***
        // Pass a GPU pointer to the vertex shader for the per mesh uniform data via a vertex attribute
        glVertexAttribI2i(m_bindlessPerMeshUniformsPtrAttribLocation, 
                             (int)(m_perMeshUniformsGPUPtr & 0xFFFFFFFF), 
                             (int)((m_perMeshUniformsGPUPtr >> 32) & 0xFFFFFFFF));
    }