Add support for ECF_D24 texture format
and prefer it over D32 for our depth buffer, this can have performance benefits
This commit is contained in:
		
							parent
							
								
									3c42cc8684
								
							
						
					
					
						commit
						4aae31ad5e
					
				| @ -328,6 +328,8 @@ public: | ||||
| 			return 32; | ||||
| 		case ECF_D16: | ||||
| 			return 16; | ||||
| 		case ECF_D24: | ||||
| 			return 32; | ||||
| 		case ECF_D32: | ||||
| 			return 32; | ||||
| 		case ECF_D24S8: | ||||
| @ -378,6 +380,7 @@ public: | ||||
| 	{ | ||||
| 		switch (format) { | ||||
| 		case ECF_D16: | ||||
| 		case ECF_D24: | ||||
| 		case ECF_D32: | ||||
| 		case ECF_D24S8: | ||||
| 			return true; | ||||
|  | ||||
| @ -77,6 +77,9 @@ enum ECOLOR_FORMAT | ||||
| 	//! 16 bit format using 16 bits for depth.
 | ||||
| 	ECF_D16, | ||||
| 
 | ||||
| 	//! 32 bit(?) format using 24 bits for depth.
 | ||||
| 	ECF_D24, | ||||
| 
 | ||||
| 	//! 32 bit format using 32 bits for depth.
 | ||||
| 	ECF_D32, | ||||
| 
 | ||||
| @ -104,6 +107,7 @@ const c8 *const ColorFormatNames[ECF_UNKNOWN + 2] = { | ||||
| 		"R16", | ||||
| 		"R16G16", | ||||
| 		"D16", | ||||
| 		"D24", | ||||
| 		"D32", | ||||
| 		"D24S8", | ||||
| 		"UNKNOWN", | ||||
|  | ||||
| @ -59,6 +59,7 @@ void COpenGL3Driver::initFeatures() | ||||
| 	TextureFormats[ECF_R16] = {GL_R16, GL_RED, GL_UNSIGNED_SHORT}; | ||||
| 	TextureFormats[ECF_R16G16] = {GL_RG16, GL_RG, GL_UNSIGNED_SHORT}; | ||||
| 	TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; | ||||
| 	TextureFormats[ECF_D24] = {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; | ||||
| 	TextureFormats[ECF_D32] = {GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; // WARNING: may not be renderable (?!)
 | ||||
| 	TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; | ||||
| 
 | ||||
|  | ||||
| @ -50,6 +50,7 @@ void COpenGLES2Driver::initFeatures() | ||||
| 		TextureFormats[ECF_R8] = {GL_R8, GL_RED, GL_UNSIGNED_BYTE}; | ||||
| 		TextureFormats[ECF_R8G8] = {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}; | ||||
| 		TextureFormats[ECF_D16] = {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; | ||||
| 		TextureFormats[ECF_D24] = {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT}; | ||||
| 		TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}; | ||||
| 
 | ||||
| 		if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888]) | ||||
|  | ||||
| @ -162,8 +162,8 @@ video::ECOLOR_FORMAT selectColorFormat(video::IVideoDriver *driver) | ||||
| 
 | ||||
| video::ECOLOR_FORMAT selectDepthFormat(video::IVideoDriver *driver) | ||||
| { | ||||
| 	if (driver->queryTextureFormat(video::ECF_D32)) | ||||
| 		return video::ECF_D32; | ||||
| 	if (driver->queryTextureFormat(video::ECF_D24)) | ||||
| 		return video::ECF_D24; | ||||
| 	if (driver->queryTextureFormat(video::ECF_D24S8)) | ||||
| 		return video::ECF_D24S8; | ||||
| 	return video::ECF_D16; // fallback depth format
 | ||||
|  | ||||
| @ -90,6 +90,10 @@ RenderStep *addPostProcessing(RenderPipeline *pipeline, RenderStep *previousStep | ||||
| 	video::ECOLOR_FORMAT color_format = selectColorFormat(driver); | ||||
| 	video::ECOLOR_FORMAT depth_format = selectDepthFormat(driver); | ||||
| 
 | ||||
| 	verbosestream << "addPostProcessing(): color = " | ||||
| 		<< video::ColorFormatNames[color_format] << " depth = " | ||||
| 		<< video::ColorFormatNames[depth_format] << std::endl; | ||||
| 
 | ||||
| 	// init post-processing buffer
 | ||||
| 	static const u8 TEXTURE_COLOR = 0; | ||||
| 	static const u8 TEXTURE_DEPTH = 1; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user