void TextureOpenGL::SetPixels(Format sourceFormat, bool synchronised, u8* data)
		{
			OpenGLContextStackLock lock;

#if !defined ION_RENDERER_KGL
			GLint glMode;
			GLint glByteFormat;
			GLint glColourFormat;
			int pixelSize = 0;
			GetOpenGLMode(sourceFormat, m_bitsPerPixel, glMode, glByteFormat, glColourFormat, pixelSize);
			int textureSizeBytes = m_width * m_height * pixelSize;

			if (m_glPixelBufferId)
			{
#if defined ION_PLATFORM_WINDOWS
				//Bind pixel buffer
				OpenGLExt::glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_glPixelBufferId);

				//Bind texture
				glBindTexture(GL_TEXTURE_2D, m_glTextureId);

				//Get buffer data ptr
				u8* pixelBufferData = nullptr;
				if (synchronised)
				{
					pixelBufferData = (unsigned char*)OpenGLExt::glMapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
				}
				else
				{
					//Synchronise
					WaitFence(m_glSyncObject);
				}

				//Copy data
				ion::memory::MemCopy(m_persistentBuffer, data, m_width * m_height * pixelSize);

				//Copy to texture
				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, glMode, glByteFormat, 0);

				//Unbind texture
				glBindTexture(GL_TEXTURE_2D, 0);

				//Unbind buffer
				OpenGLExt::glBindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
#endif
			}
			else
			{
				//Copy direct to texture
				glBindTexture(GL_TEXTURE_2D, m_glTextureId);
				glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, glMode, glByteFormat, data);
				glBindTexture(GL_TEXTURE_2D, 0);
			}

			RendererOpenGL::CheckGLError("TextureOpenGL::SetPixels");
#endif
		}
Esempio n. 2
0
void D3D12CommandQueue::WaitIdle()
{
    /* Submit intermediate fence and wait for it to be signaled */
    Submit(intermediateFence_);
    WaitFence(intermediateFence_, ~0ull);
}