Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: radeon: The kernel rejected CS, see dmesg for more information.  (Read 13116 times)

0 Members and 1 Guest are viewing this topic.

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
radeon: The kernel rejected CS, see dmesg for more information.
« on: September 05, 2012, 04:00:53 pm »
Hi!

I have a problem with the latest build of SFML2RC.

When I try to run
#include "IntroState.hpp"
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace sf;
using namespace std;

IntroState::IntroState()
{
        splashTex = new Texture();
        splashTex->loadFromFile("splash.png");

        splash = new Sprite(*splashTex);
}

IntroState::~IntroState()
{
        delete splash;
        delete splashTex;
}

void IntroState::handleEvents(sf::RenderWindow *window)
{
        Event e;
        while(window->pollEvent(e))
        {
                if(e.type == Event::Closed)
                {
                        window->close();
                        cout << "closed" << endl;
                }
        }
}

void IntroState::draw(sf::RenderWindow *window)
{
        cout << "will now draw..." << endl;
        window->draw(*splash);
        cout << "drawn" << endl;

}

the created window looks weird and I get:
Quote
radeon: The kernel rejected CS, see dmesg for more information.

dmesg says:
Quote
[  507.205263] radeon 0000:01:05.0: alignments 832 1 1 1
[  507.205269] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !
[  507.233217] radeon 0000:01:05.0: texture bo too small (800 600 26 0 -> 1920000 have 4096)

BUT:
When I put con- and destructor in draw(), like this:
void IntroState::draw(sf::RenderWindow *window)
{      
        splashTex = new Texture();
        splashTex->loadFromFile("splash.png");
        splash = new Sprite(*splashTex);
       
        cout << "will now draw..." << endl;
        window->draw(*splash);
        cout << "drawn" << endl;
       
        delete splash;
        delete splashTex;
}
it works!

I have no idea how to solve this problem. Maybe you have an idea?

If so, feel free to help.

greets, mobai

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #1 on: September 05, 2012, 04:14:40 pm »
Does the IntroState maybe get destroyed before the draw function is called?

Check what happens if you remove the delete from the state's destructor. Just to make sure that isn't the problem.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #2 on: September 05, 2012, 04:19:33 pm »
Sorry, but it looks like that's not the problem. It still doesn't work  :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #3 on: September 05, 2012, 05:00:30 pm »
We must see how your IntroState object is used. Could you please write a complete and minimal example that reproduces the problem?
Laurent Gomila - SFML developer

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #4 on: September 05, 2012, 05:06:03 pm »
the tar.lzma contains everything you need, incl. headers.

main.cpp:
#include "Game.hpp"
#include "IntroState.hpp"
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
        IntroState iSt;

        Game game(800, 600, "Test");
        game.changeState(&iSt);

        while(game.isOpen()){
                game.handleEvents();
                game.draw();
        }
}
 
Game.cpp:
#include "Game.hpp"
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>

using namespace std;

Game::Game(int x, int y, std::string label)
{
        window = new sf::RenderWindow(sf::VideoMode(x, y), label);
}


Game::~Game()
{
        delete window;
}

void Game::changeState(State *state)
{
        currentState = state;
}

void Game::handleEvents()
{
        currentState->handleEvents(window);
}

void Game::draw()
{
        window->clear();
        currentState->draw(window);
        window->display();
        cout << "displayed" << endl;
}

bool Game::isOpen()
{
        return window->isOpen();
}
IntroState.cpp:
#include "IntroState.hpp"
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace sf;
using namespace std;

IntroState::IntroState()
{
        splashTex = new Texture();
        splashTex->loadFromFile("splash.png");

        splash = new Sprite(*splashTex);
}

IntroState::~IntroState()
{
        delete splash;
        delete splashTex;
}

void IntroState::handleEvents(sf::RenderWindow *window)
{
        Event e;
        while(window->pollEvent(e))
        {
                if(e.type == Event::Closed)
                {
                        window->close();
                        cout << "closed" << endl;
                }
        }
}

void IntroState::draw(sf::RenderWindow *window)
{
        cout << "will now draw..." << endl;
        window->draw(*splash);
        cout << "drawn" << endl;

}[code]

[attachment deleted by admin]
« Last Edit: September 05, 2012, 05:13:02 pm by mobai »

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #5 on: September 05, 2012, 05:22:39 pm »
With minimal he means one source file with only a main function. But this is small enough so I guess it works. It seems from the error message that it is having problems with the texture for the window. I guess the sprite isn't 800x600 right? Try increasing it's size to something a lot bigger and see what happens?

To me it looks like you are on Linux right? Try reinstalling the drivers and the mesa packages.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #6 on: September 05, 2012, 05:27:33 pm »
No, it's exactly 800x600. But I'll try it.

EDIT: 8000x6000 doesn't work
« Last Edit: September 05, 2012, 05:39:06 pm by mobai »

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #7 on: September 05, 2012, 05:49:43 pm »
Thaaat's way too big. I was thinking of like maybe: 1600x1200 or something like that.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #8 on: September 06, 2012, 05:53:01 pm »
Ok, this one is more minimal:
http://pastebin.com/0AhwCbqy

By the way: I tested the program on another PC (32-bit) and it didn't work.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #9 on: September 06, 2012, 08:24:20 pm »
You could've also posted it here, instead of using pastebin... :P

I guess your problem is this bug, at least it fits perfectly your 'symptoms'. ;)
Try to put the Game class initialization in front of the IntroState initialization.

Although you've only posted example code I'll still give you some hints on how to make it better. ;)
  • You're Game class gets instanciated to a unstable state, because the state member variable doesn't get initialized with NULL/nullptr. Thus if one would call handelEvents or draw without calling changeState before, the behavior would be undefined = crash. But that will also happen if it's set to nullptr, because you can't call a member function of a non-existing object, thus you'll need to check the existence before proceeding.
  • Don't use pointers if it's not necessary, but use references and const references. (e.g. there's no reason for the RenderWindow to be allocated on the heap and managed with a pointer. Or there's no reason to pass the RenderWindow around as pointer instead of a reference.)
  • It's adised to use smart pointers over normal pointers which will eliminate all 'delete' calls and with the factory functions make_shared() and make_unique() also all 'new' calls, which leads to a more stable and error proof code design.
  • Make sure that all member variable get initialized!
« Last Edit: September 06, 2012, 08:34:19 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mobai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #10 on: September 07, 2012, 03:12:05 pm »
OMG, eXpl0it3r, you're awesome. It  works.  ;D

I tried not to use pointers and heap, but it didn't work (?).

Could you please give me an example of how to do it better?

EDIT:
ah, now I got it. The only pointer I have now is currentState
« Last Edit: September 07, 2012, 03:35:35 pm by mobai »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #11 on: September 07, 2012, 03:49:32 pm »
OMG, eXpl0it3r, you're awesome. It  works.  ;D
Glad I could help. :)

I tried not to use pointers and heap, but it didn't work (?).
Could you please give me an example of how to do it better?
What do you mean with "It didn't work"?

Anyways I've quickly made the changes to your code: http://pastebin.com/iHJhmf7E
I haven't tested it, but I guess it should work fine.

If you don't understand how references or initialization lists work, you should defently go back to your C++ book and reread those sections. ;)

On my GitHub account I've also got a repository with a SmallGameEngine = state machine, that makes use of unique_ptr rather than raw pointers for managing states. The code could need a bit of a clean up but feel free to use whatever parts you want. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #12 on: September 07, 2012, 04:12:24 pm »
Quote
...go back to your C++ book...
Every time you say that I'm crying somewhere in the distance.  :'(
Quote
that makes use of unique_ptr rather than raw pointers for managing states
Only in c++11 tho, in 03 there's a slightly different auto_ptr.
using namespace std;
using namespace sf;
Hope you're not doing that in actual code, this is not considered good practice.
Especially the first one, std has tons of things in it, some names might clash and it makes reading code a pain.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #13 on: September 07, 2012, 04:14:03 pm »
Every time you say that I'm crying somewhere in the distance.  :'(
Why? ???
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: radeon: The kernel rejected CS, see dmesg for more information.
« Reply #14 on: September 07, 2012, 04:19:32 pm »
I have no c++ book.
Back to C++ gamedev with SFML in May 2023

 

anything